Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cycling through variables

Status
Not open for further replies.

drewson

MIS
Jun 3, 2003
50
US
I am loading a number of variables from a text file:
news1
news2
news3
...

I want to cycle through them to manipulate their values until I get to the last defined variable (so I can put as many variables in the text file as I please. I've tried using a for loop, but I think I've got the wrong syntax:

for (i = 1; ["news" + i] != undefined; i = i + 1 ){
<manipulation steps here>
}

Any ideas?

Thanks!
drewson
 
add one more varaible to the text file...NumItems (say)

use loadvars for the text file

then as part of the onload function

numitems =mydata.NumItems;
mydata the loadvars object

for(1=0;1<numitems;i++){
<manipulation steps here>
}

 
I'm trying to find a way that I don't have to specify the number of variables to cycle through (kind of like using an end of file method in VB). If I'm right, NumItems would be a variable that contains the number of variables? Is there any other way?
 
just use one variable in the text file and have a delimiter ( the | key perhaps)

then in flash

once varaible has loaded using

split(&quot;|&quot;);

will put each variable in as an element of an array

you can then use the array length arguement instead of the extra variable numitems in the for statement
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top