Create variable in runtime from string - Forum

Forum Navigation
You need to log in to create posts and topics.

Create variable in runtime from string

So for example if...

...I am having code like this:

SetVar [myobject.name] "John"
SetVar [myobject.age] 43

and then I want to LoopObject like this:

LoopObject [property] [myobject]

   Here I want to use syntax for example like this:
   IsVarEmpty[property as variable][result]

EndLoop

So is it possible to create a variable on the fly from string.

@kajanken not sure if I'm understanding you, but you can create a variable at run time whose name come from a string using JavaSctip like this:

SetVar [variableName] "hi"
BeginJS
 theName = $App.variableName;
 $App[theName] = "Hello world!"
EndJS
jsAlert "[hi]"

I hope it helps.