Try OpenEdge Now
skip to main content
ABL Reference
ABL Syntax Reference : LEAVE statement
 

LEAVE statement

Exits from a block. Execution continues with the first statement after the end of the block.

Syntax

LEAVE [ label ]
label
The name of the block you want to leave. If you do not name a block, the AVM leaves the innermost iterating block that contains the LEAVE statement. If there is no such block, then the AVM leaves the procedure block.

Example

This procedure represents part of a menu program. If the user chooses N, P, F, or Q, the procedure leaves the inner choose block and goes on to process the menu selection. If the user presses any other key, the procedure rings the terminal bell.
r-leave.p
DEFINE VARIABLE valid-choice AS CHARACTER NO-UNDO INITIAL "NPFQ".
DEFINE VARIABLE selection    AS CHARACTER NO-UNDO FORMAT "x".

main-loop:
REPEAT:
choose:
REPEAT ON ENDKEY UNDO choose, RETURN:
MESSAGE "(N)ext (P)rev (F)ind (Q)uit"
UPDATE selection AUTO-RETURN.
    /* Selection was valid */
IF INDEX(valid-choice, selection) <> 0 THEN LEAVE choose.
BELL.
END. /* choose */

  /* Processing for menu choices N, P, F here */
  IF selection = "Q" THEN LEAVE main-loop.
END. /* REPEAT */

See also

NEXT statement, RETURN statement, UNDO statement