EXIT

BS2 icon BS2e icon BS2sx icon BS2p icon BS2pe icon BS2px icon

EXIT Example

 

 

 

Syntax: EXIT

Function

Causes the immediate termination of a loop construct (FOR…NEXT, DO…LOOP).

Quick Facts

  All BS2 Models
Maximum EXITs per loop 16
Related Commands FOR…NEXT, DO…LOOP

Explanation

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.

Go to PBASIC Language home page

Open Getting Started with Stamps in Class

Open Connection Troubleshooting

BASIC Stamp Help Version 2.5.4

Copyright © Parallax Inc.

8/21/2013