[Coco] RE: Bug in FOR NEXT ?
Ries, Rich [S&FS]
Rich.Ries at Honeywell.com
Mon Jun 5 10:43:15 EDT 2006
So, to get a "proper" FOR-NEXT loop, you'd need to do something like
this:
10 IF UPPER < LOWER THEN GOTO 90
20 FOR N = LOWER TO UPPER
30 ' do something
50 IF condition THEN N = UPPER+1
60 'do something else
80 NEXT N
90 ' Continue
If you test the loop variable to check for an early exit, then setting N
to UPPER+1 or greater should do the trick. Or you may want to use a
separate exit value, which would allow multiple exit points:
5 EV = 0
10 IF UPPER < LOWER THEN GOTO 110
20 FOR N = LOWER TO UPPER
30 ' do something
50 IF NOT condition THEN GOTO 90
60 N = UPPER+1
70 EV = 12
80 GOTO 100
90 'do something else
100 NEXT N
110 ' Test EV
--Rich
More information about the Coco
mailing list