EXIT block-name

The EXIT block instruction transfers control out of the current program block.

Syntax

EXIT
 { CASE
 | FOR
 | FOREACH
 | WHILE
 | MENU
 | CONSTRUCT
 | REPORT
 | DISPLAY
 | INPUT
 | DIALOG }

Usage

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