Leave Instruction; Iterate Instruction - IBM TSO/E REXX User Manual

Table of Contents

Advertisement

Using Looping Instructions
This example sends data sets to the printer and then issues a message that the
data set was printed. When the user enters a blank, the loop ends and so does the
exec. To end the loop without ending the exec, use the LEAVE instruction, as
described in the following topic.

LEAVE Instruction

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:

ITERATE Instruction

Another instruction, ITERATE, stops execution from within the loop and passes
control to the DO instruction at the top of the loop. Depending on the type of DO
instruction, a control variable is increased and tested and/or a condition is tested to
determine whether to repeat the loop. Like LEAVE, ITERATE is used within the
loop.
DO count = 1 TO 10
50
z/OS V1R1.0 TSO/E REXX User's Guide
Example Using a DO FOREVER Loop
/****************************** REXX *******************************/
/* This exec prints data sets named by a user until the user enters*/
/* a null line.
/*******************************************************************/
DO FOREVER
SAY 'Enter the name of the next data set or a blank to end.'
PULL dataset_name
IF dataset_name = '' THEN
EXIT
ELSE
DO
"PRINTDS DA("dataset_name")"
SAY dataset_name 'printed.'
END
END
Example Using the LEAVE Instruction
/******************************** REXX *****************************/
/* This exec uses the LEAVE instruction to exit from a DO FOREVER */
/* loop that sends data sets to the printer.
/*******************************************************************/
DO FOREVER
SAY 'Enter the name of the next data set.'
SAY 'When there are no more data sets, enter QUIT.'
PULL dataset_name
IF dataset_name = 'QUIT' THEN
LEAVE
ELSE
DO
"PRINTDS DA("dataset_name")"
SAY dataset_name 'printed.'
END
END
SAY 'Good-bye.'
IF count = 8
THEN
*/
*/

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents