IBM SC34-5764-01 Manual page 63

Cics transaction server for vse/esa
Table of Contents

Advertisement

/******************************* REXX ********************************/
/* This program processes strings until the value of a string is
/* a null string.
/*********************************************************************/
DO FOREVER
PULL string
IF string = '' THEN
PULL file_name
IF file_name = '' THEN
EXIT
ELSE
DO
result = process(string)
IF result = 0 THEN SAY "Processing complete for string:" string
ELSE SAY "Processing failed for string:" string
END
END
Figure 20. Example Using a DO FOREVER Loop
This example sends strings to a user-written function for processing and then issues a message that the
processing completed successfully or failed. When the input string is a blank, the loop ends and so does
the program. You can also end the loop without ending the program by using the LEAVE instruction. The
following topic describes this.
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:
/******************************** REXX *******************************/
/* This program uses the LEAVE instruction to exit from a DO
/* FOREVER loop.
/*********************************************************************/
DO FOREVER
PULL string
IF string = 'QUIT' then
LEAVE
ELSE
DO
result = process(string)
IF result = 0 THEN SAY "Processing complete for string:" string
ELSE SAY "Processing failed for string:" string
END
END
SAY 'Program run complete.'
Figure 21. Example Using the LEAVE Instruction
ITERATE Instruction
The ITERATE instruction 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, the language processor increases and tests
a control variable or tests a condition to determine whether to repeat the loop. Like LEAVE, ITERATE is
used within the loop.
DO count = 1 TO 10
IF count = 8
THEN
ITERATE
ELSE
SAY 'Number' count
END
This example results in a list of numbers from 1 to 10 with the exception of number 8.
/* Gets string from input stream */
/* Calls a user-written function */
/* to do processing on string.
/* Gets string from input stream
/* Calls a user-written function */
/* to do processing on string.
Control Flow within a Program
*/
*/
*/
*/
*/
*/
*/
Chapter 4. Controlling the Flow within a program
41

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Rexx

Table of Contents