Language basics / Flow control |
The EXIT block instruction transfers control out of the current program block.
EXIT { CASE | FOR | FOREACH | WHILE | MENU | CONSTRUCT | REPORT | DISPLAY | INPUT | DIALOG }
The EXIT block-name instruction transfers control out of a control structure (a block, a loop, a CASE statement, or an interface instruction).
The EXIT block-name instruction must be used inside the control structure specified by block-name. For example, EXIT FOR can only appear inside a FOR ... END FOR iteration block.
EXIT DISPLAY exits the DISPLAY ARRAY instruction and EXIT INPUT exits an INPUT or an INPUT ARRAY block.
EXIT CONSTRUCT exits current CONSTRUCT block.
EXIT DIALOG exits current DIALOG block.
To exit a function, use the RETURN instruction. To terminate a program, use the EXIT PROGRAM instruction.
MAIN DEFINE i INTEGER LET i = 0 WHILE TRUE DISPLAY "This is an infinite loop. How would you get out of here?" LET i = i + 1 IF i = 100 THEN EXIT WHILE END IF END WHILE DISPLAY "Done." END MAIN