Click on a class name to see the description of that particular class:
static obj GetIndVariable(int index=1, string *name, boolean sorted=false, string scope="local", int stackIndex)
Get variables list of current script
The GetIndVariables returns the value of the variable corresponding to a given position in the "list" of current script variables and, optionally, the name of the variable itself.
"Lists" are relative to scopes; each scope maintains a list with all variables (of the current script) belonging to that scope (and to specify a list means to specify a scope).
the index of the variable in the list
on output, the name of the variable requested
specifies if the list must be sorted alphabetically, before getting the index-th variable
defines the list to get the variable from. Possible lists corresponds to possible scopes: local, global, application, session, persistent
Example: the following script prints all local variables (with their names) of the current script
totVars = curScript.GetTotVariables("local")
theVar = ""
for(i = 1; i <= totVars; i++)
theVar = curScript.GetIndVariable(i, &name, false, "local")
$name + ": " + theVar + "<br>"
Note that the variables i, totVars and theVar will not be included in the printed list because they have been defined after the GetTotVariables call.
Besides, note that theVar is initialized before the loop (to empty string) in order to define its class and to avoid typecast problems. Without that initialization, if the first variable of the list is an int theVar is initialized to int and following typecasts could fail if subsequent variables are not numbers (that is a common case).
Return to the curScript class