PDA

View Full Version : setting _global variables in loops


Graphfixz
05-29-2003, 07:05 PM
I have the following code:

Name_lenth = 10

for (i = 0; i < Name_length; i++) {

var varName;
_global.varName = Name_array[i];

}


and it works but how would I set a variable for every loop. The follwoing won't work:

_global.varName + [i] = Name_array[i];
_global.varName[i] = Name_array[i];

any ideas how I can create 10 vars in this loop?

Thanks in advance!

senocular
05-29-2003, 07:08 PM
_global["varname"+ i] =


then you get
_global.varname1,
_global.varname2,
_global.varname3,
etc.

...unless you want varname to be an array, then you can use
_global.varname[i];
but first you have to declare varname to be one (an array)

_global.varname = []
// loop

Graphfixz
05-29-2003, 07:20 PM
You guys are great!

After looking and researching for an answer for hours it only took but a minute from you guys.


Thanks!