Stuck in a loop?
Posted: Sun Jun 22, 2008 4:09 pm
I have code like this
repeat with i = theTotal to 1 step -1
if z < 29 then
put hArray into uhArray[z]
add 1 to z
else
put theTotal into i
end if
end repeat
z = 1 at the start.
theTotal > 50
hArray contains a list of numbers (not
consecutive) and I want to get the last 28
unique numbers so that I can get the
unused numbers. (The code above doesn't
detect repeat numbers).
The question is "Why does the loop keep
repeating after theTotal is put into i?
It should come out of the repeat loop, I feel.
This is the only way I can see to exit the loop
without making it into a separate handler. It's
something I've used in other languages with no
problems.
Any ideas welcome including how to detect
duplicates and not put them into uhArray a
second time.
Perhaps a field is the answer but should be
able to do it with arrays.
repeat with i = theTotal to 1 step -1
if z < 29 then
put hArray into uhArray[z]
add 1 to z
else
put theTotal into i
end if
end repeat
z = 1 at the start.
theTotal > 50
hArray contains a list of numbers (not
consecutive) and I want to get the last 28
unique numbers so that I can get the
unused numbers. (The code above doesn't
detect repeat numbers).
The question is "Why does the loop keep
repeating after theTotal is put into i?
It should come out of the repeat loop, I feel.
This is the only way I can see to exit the loop
without making it into a separate handler. It's
something I've used in other languages with no
problems.
Any ideas welcome including how to detect
duplicates and not put them into uhArray a
second time.
Perhaps a field is the answer but should be
able to do it with arrays.