Causes the immediate termination of a loop construct (FOR…NEXT, DO…LOOP).
|All BS2 Models|
|Maximum EXITs per loop||16|
|Related Commands||FOR…NEXT, DO…LOOP|
The EXIT command allows a program to terminate a loop structure before the loop limit test is executed. While not required, EXIT is usually used as part of an IF...THEN construct to test a secondary condition for terminating a loop, or for testing a termination condition of an unconditional DO...LOOP structure.
col VAR Byte row VAR Byte Main: FOR col = 0 TO 3 FOR row = 0 TO 15 IF (row > 9) THEN EXIT DEBUG CRSRXY, (col * 8), row, DEC row, CR NEXT NEXT END
In this program, the FOR row = 0 TO 15 loop will not run past nine because the IF (row > 9) THEN EXIT contained within will force the loop to terminate when row is greater than nine. Note that the EXIT command only terminates the loop that contains it. In this program, the outer loop (col) will continue to run until complete.
BASIC Stamp Help Version 2.5.4
Copyright © Parallax Inc.