Progress
Language Reference


LEAVE Statement

Interfaces
OS
SpeedScript
All
All
Yes

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, Progress leaves the innermost iterating block that contains the LEAVE statement. If there is no such block, then Progress 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 INITIAL "NPFQ".
DEFINE VARIABLE selection AS CHARACTER 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.
    IF INDEX(valid-choice, selection) <> 0
    THEN LEAVE choose. /* Selection was valid */
    BELL.
  END.  /* choose */

/* Processing for menu choices N, P, F here */

  IF selection = "Q" THEN LEAVE main-loop.
END. 

SEE ALSO

NEXT Statement, RETURN Statement, UNDO Statement


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095