Page 1 of 1

Local variables in repeat

Posted: Tue Aug 19, 2014 2:22 am
by sincipient820
I have 8 local variables that I need to put into 8 corresponding fields. I'm wondering how I can do this with repeat. My code doesn't work but is as follows....

Code: Select all

locals svar1
local svar2 ----and so on until local svar8

put 5 into svar1
put 8 into svar2 --- and so on with different starting points

repeat with i =1 to 8
      put "svar" & i into tvar
      put "field" & i into tfield
      if (sFrame/10) is an integer then
         add 1 to tvar
         put tvar into field tfield of me
      end if      
   end repeat
the problem here is that the local variables don't appear to be recognized in the repeat. Rather it seems to treat it as a string resulting in "var1", "var2",....ect. So is there a way to identify multiple local variables in a repeat like this?

Thanks

Re: Local variables in repeat

Posted: Tue Aug 19, 2014 4:10 am
by Thierry
sincipient820 wrote:I have 8 local variables that I need to put into 8 corresponding fields. I'm wondering how I can do this with repeat. My code doesn't work but is as follows....
You can use arrays.

Code: Select all

put 5 into sVar[1]
put 8 into sVar[2]
.....
add 1 to sVar[ i]
.....
and you could try the modulo instead of sFrame/10 is an integer.

Regards,
Thierry

Re: Local variables in repeat

Posted: Tue Aug 19, 2014 9:26 pm
by sincipient820
Thanks that's the solution I was looking for.