Automatically assign a value to a set of variables

Post your questions and help other users.

Moderator: Martin

Post Reply
Giovanni
Posts: 5
Joined: 01 Aug 2015 07:38

Automatically assign a value to a set of variables

Post by Giovanni » 01 Aug 2015 07:59

Greetings to all, this is my first message!
I apologize if I make a silly question ...

I need to automatically assign a value to variables:

for (i in [1 to 10])
{
var (i) = value (i);
}

How can I do?

bogdyro
Posts: 241
Joined: 04 Apr 2015 15:14

Re: Automatically assign a value to a set of variables

Post by bogdyro » 01 Aug 2015 10:58

Do you need dynamically named variables? Like a1=1, a2=2, and so on?
for (i in [1 to 10])
{
eval('variableName'+"{i}"+'=i');
}

Giovanni
Posts: 5
Joined: 01 Aug 2015 07:38

Re: Automatically assign a value to a set of variables

Post by Giovanni » 01 Aug 2015 11:18

Perfect, it was just what I wanted! Thank you.
I use automagic long enough but only for very simple tasks. Only recently I started to try the more advanced features.

I hope that you all want to help me to use more professionally Automagic.

Its author is a genius.

Post Reply