PDA

View Full Version : Complete Loss of Brain Power...Variable problem stuck like chuck


TimeSurfer
01-26-2008, 09:53 PM
As I stated above im stuck like chuck lol.
How can I use the string value of 1 variable as the name of another.


EXAMPLE -

var1 = 'testing'
var2 = 30

im trying to automatically create the variable below from the ones above if that makes sense.

testing = var2

Is this even at all possible in AMS???

bule
01-27-2008, 04:50 AM
Is this even at all possible in AMS???

Yes, but you should use tables:

myvar = {};

myNewVarName = 'UberCoolVar';
myRandomValue = 30;

myvar[myNewVarName] = myRandomValue;

So, you can always reference to this value using table approach.
If you would (hypothetically) know the name variable in front,
you could access it like this as well:

someHardCoredVar = myvar.UberCoolVar;

You can put as much custom variables as you want in this table as you please.

Mina
01-27-2008, 05:55 AM
Hi.
Well, it is possible in AMS :lol

here, try this (in attachment) and tell me how it goes
(In input 2, don't forget the quotation marks when assigning a string value)

(also, to test if the variable exists. you could use Dialog.Message or Input.SetText, etc.)

As I stated above im stuck like chuck lol.
How can I use the string value of 1 variable as the name of another.


EXAMPLE -

var1 = 'testing'
var2 = 30

im trying to automatically create the variable below from the ones above if that makes sense.

testing = var2

Is this even at all possible in AMS???

TimeSurfer
01-27-2008, 02:19 PM
thank you mina, thanks bule ill try them both appreciate the help very much