View Full Version : variable name and array
Timmins
08-30-2005, 06:04 PM
I am having difficulty writing the script to check the value of an element of an array (say ZArray) using a for/next loop. I have three variables called G1, G2, G3 that contain the element numbers that I want to check using a for/next loop, rather than 3 separate routines. I would appreciate any suggestions how to write this (that is G?):
for (x;x<4;x++){
if (ZArray[G?]==some value){
do this
}
}
Thanks again.
for (x=0; x<4; x++){
if (ZArray[x] == someValue){
//do this
}
}
Timmins
08-30-2005, 06:57 PM
Thanks for your help, sorry I wasn't clear on the difficulty. I would like to test three different variables, called G1, G2, G3 using a for/next loop, so that instead of writing:
if y==ZArray[G1] etc.
if y==ZArray[G2] etc.
if y==ZArray[G3] etc.
I would like to write something like
for (x=1;x<4;x++){
if (y==ZArray["G"+x]) {etc
}
}
Any suggestions are appreciated.
What values will G1, G2, and G3 have. For example, will they be holding a number or actual data?
Timmins
08-30-2005, 07:58 PM
They will be holding numbers ?and data in the sense that their value will vary, ie G1 may = 3 or 5, etc. Thanks again.
for (x=1;x<4;x++){
if (y==ZArray[_root["G"+x]]) {etc
}
}
Timmins
08-30-2005, 08:15 PM
Thanks everyone for your help!
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.