Hi Nakia,
well, there are two possibilities top use repeat":
1.
Code: Select all
repeat with i = 1 to the num of lines of fld XYZ
## do someting with "line i of fld XYZ"
end repeat
This will do for most cases and is fast enough for lots of repeats.
But when unsing "repeat with x =..." the engine will always start to count from 1 (or your start value).
Here: i = the current number of the loop
#################################################################
2. For VERY fast "repeat" loops you can use "repeat for each..."
Code: Select all
repeat for each line i in MyVar
## do something
end repeat
The min difference is that i is NOT a number here but the CONTENT of that line!
Advantage:
The engine is just passing the values to your handler and does NOT count from 1 every time!
THIS IS INSANELY FAST!!!!!!!
Means processing several thousand of lines in fractions of a seconds, depending on your handlers!
Disadvantage:
a. You cannot alter/modify i in this case:
Code: Select all
repeat for each line i in MyVar
## this does not work!
delete char 1 of i
end repeat
Do something lime this:
Code: Select all
repeat for each line i in MyVar
## this does not work!
put i into i2
delete char 1 of i2
put i2 & CR after myNewList
end repeat
## Get rid of trailing CR
delete char -1 of MyNewList
## do something with this variuable
b. I f you need a counter though, you need to create your own:
Code: Select all
put 0 into tCounter
repeat for each line i in MyVar
add 1 to tCounter
## do something
end repeat
...
REPEAT FOR EACH does not support all kind of loops:
repeat for each cd i in this stack #not works
Check the dictionary for more info.
Best
Klaus