EXIT FOR Keyword
Syntax
EXIT FOR
Parameters
None – This keyword takes no arguments.
Description
EXIT FOR terminates the execution of the nearest enclosing FOR EACH … IN … NEXT loop prematurely. When the interpreter encounters EXIT FOR, it stops iterating over the collection and continues execution after the NEXT statement that matches the loop variable.
Example
FOR EACH item IN my_list
IF item = "stop" THEN
EXIT FOR
ENDIF
TALK item
NEXT item
TALK "Loop ended."
In this script, the loop stops as soon as item equals "stop", and the subsequent TALK "Loop ended." is executed.
Usage Notes
EXIT FORcan only be used inside aFOR EACH … IN … NEXTblock.- It does not accept any parameters; it simply signals an early exit.
- The keyword is case‑insensitive;
exit forworks the same way.