Using a variable in a loop

what is the proper syntax/method for using the variable “total” in the following loop? And how do I make sure the value of total is a number and not a string of text?

for (i=1; i<=total; ++i){
&nbsp&nbsp&nbsp&nbspvar returned = returned+"
"+search[“Summary” +i];


Just test it:

for (i=0;i < total;i++) trace (i);

returns 0 1 2 3 4

for (i=0;i < total;i++) trace (i);

returns… 0 1 2 3 4

pom :asian:

can you answer the first part (about proper syntax)?

I get an error when I use the above script when i use the variable “total” but if i put a static number in there it works fine.

Also I know that I am getting a value for the total variable as I am using the trace function to figure out if it is actually working.


I tried them on my computer, both work (with MX but it must be the same with 5).

pom :asian:

I’m pulling my total variable in via a string from a web page, the string looks like this “&TotalRecords=2” that string if i trace it gives me the result “2”

however if I look at my variables in the project (from the debugger) I have the value TotalRecords:"2 " any idea what that means?


in case you are wondering… problem solved.

The problem lied in the coldfusion page that was processing my request.

Be weary, if you write a page in coldfusion or any other dynamic style page and pass values back to flash. Flash will use any spaces in your string and interpret those spaces. In my case it added the " " tag, which in flash is interpreted as a tab.