Re: for puzzlement
- Posted by petelomax Jan 11, 2019
- 1305 views
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 (unless you pre-declare it)
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, btdt.
Pete