Syntax

Leaves the innermost loop at once. The program continues after its NEXT, ENDWHILE, UNTIL or LOOP.

EXIT

Good to know

  • It acts on the innermost FOR, FOREACH, WHILE, REPEAT or DO loop. Inside a SELECT, it leaves the loop around the SELECT, not only the SELECT.
  • Outside any loop it is a compile error: "EXIT without an active loop". That includes a SELECT that is not inside a loop.
  • There is one spelling. EXIT FOR, EXIT WHILE, EXIT DO and Break are not supported: EXIT FOR compiles, but the program does not start. Write EXIT.
  • EXIT leaves one loop. To leave two nested loops, set a flag and test it in the outer loop, or jump forward with GOTO.
  • To leave a FUNCTION, use EXITFUNCTION, not EXIT.

Example

FOR i = 1 TO 10  IF i * i > 20 THEN EXITNEXTConsole(Str(i))   ' 5
In the manual : Control flow