The LEAVE instruction causes an immediate exit from a repetitive
loop. Control goes to the instruction following the END keyword of
the loop. An example of using the LEAVE instruction follows:
Figure 1. Example
Using the LEAVE Instruction/******************************** REXX *******************************/
/* This program uses the LEAVE instruction to exit from a DO */
/* FOREVER loop. */
/*********************************************************************/
DO FOREVER
PULL string /* Gets string from input stream */
IF string = 'QUIT' then
LEAVE
ELSE
DO
result = process(string) /* Calls a user-written function */
/* to do processing on string. */
IF result = 0 THEN SAY "Processing complete for string:" string
ELSE SAY "Processing failed for string:" string
END
END
SAY 'Program run complete.'