Historical forum-msg-id-133391-edit, Revision 1

Original date:2019-01-11 04:34:38 Edited by: petelomax Subject: Re: for puzzlement

euphoric said...
petelomax said...

Well, I never. Pre-declaring loop variables has worked for so long in phix that I forgot you cannot do that in OE.

Somebody catch me up: Why would you pre-declare your loop variables?

So you can look see how far the loop got before exiting, especially useful if it has multiple exit points, and/or if the whole point of the loop was just to set i anyway.

for i=1 to length(s) do 
    if this then exit end if 
    if that then exit end if 
    if the other then exit end if 
end for 
?i -- oops, error 

The only other sensible alternative would be to pre-declare another variable say ifail and set it to i at the top of the loop.


Not Categorized, Please Help


Quick Links

User menu

Not signed in.

Misc Menu