Page 1 of 1

Multiple Variable on Repeat Functrion .... ?

Posted: Sat Sep 22, 2018 4:17 am
by gilar
From what i know ... Repeat function usually only one variable
ex:
repeat with i = 1 to 12
--------
end repeat
Is it possible to put 2 or more variable on repeat function?
ex:

repeat with i = 1 to 10, and j with = 10 to 20 (try this code but no luck)
--------
end repeat

this is my code

Code: Select all

on mouseUp
   repeat with i = 1 to 12
         put "<componentData id=\"& quote&"tName"&i&"\"&quote&"><data id=\"&quote&"text\"&quote&" value=\"&quote&"tValue"&i&"\"&quote &"/></componentData>" into field test_fld
   end repeat
end mouseUp

Comment and help would be appriciate


Best Regards



Gilar Kadarsah

Re: Multiple Variable on Repeat Functrion .... ?

Posted: Sat Sep 22, 2018 4:21 am
by FourthWorld
Since the range within a loop is the same, you can maintain the var j within the loop by just adding to i:

Code: Select all

repeat with i = 1 to 10
   put i+9 into j
   DoSomethingWith i,j
end repeat

Re: Multiple Variable on Repeat Functrion .... ?

Posted: Sat Sep 22, 2018 3:40 pm
by dunbarx
Or you can nest the loops:

Code: Select all

on mouseUp
   repeat with y = 1 to 10
  repeat with x = 1 to 10
      put y & comma & x & return after accum
    end repeat
 end repeat
 put accum into fld 1
end mouseUp
You can nest farther if you need to...

Craig Newman

EDIT: I have gone as far as four levels. It wasn't my fault.