regardless of whether the user enters "quit", "QUIT", or "Quit", the language
processor translates the input to uppercase before comparing it to "QUIT".
Conditional Loops
There are two types of conditional loops, DO WHILE and DO UNTIL. Both types of
loops are controlled by one or more expressions. However, DO WHILE loops test
the expression before the loop executes the first time and repeat only when the
expression is true. DO UNTIL loops test the expression after the loop executes at
least once and repeat only when the expression is false.
DO WHILE Loops
DO WHILE loops in a flowchart appear as follows:
As REXX instructions, the flowchart example looks like:
DO WHILE expression
/* expression must be true */
instruction(s)
END
Use a DO WHILE loop when you want to execute the loop while a condition is true.
DO WHILE tests the condition at the top of the loop. If the condition is initially false,
the loop is never executed.
You can use a DO WHILE loop instead of the DO FOREVER loop in the example
using the “LEAVE Instruction” on page 50. However, you need to initialize the loop
with a first case so the condition can be tested before you get into the loop. Notice
the first case initialization in the beginning three lines of the following example.
Example Using DO WHILE
/******************************** REXX *****************************/
/* This exec uses a DO WHILE loop to send data sets to the system */
/* printer.
*/
/*******************************************************************/
SAY 'Enter the name of a data set to print.'
SAY 'If there are no data sets, enter QUIT.'
PULL dataset_name
DO WHILE dataset_name \= 'QUIT'
"PRINTDS DA("dataset_name")"
SAY dataset_name 'printed.'
SAY 'Enter the name of the next data set.'
SAY 'When there are no more data sets, enter QUIT.'
PULL dataset_name
END
SAY 'Good-bye.'
DO WHILE
END
expression
True
False
instruction(s)
Using Looping Instructions
52
z/OS V1R1.0 TSO/E REXX User’s Guide
Summary of Contents for TSO/E REXX
Page 1: ...z OS TSO E REXX User s Guide SA22 7791 00 ...
Page 2: ......
Page 3: ...z OS TSO E REXX User s Guide SA22 7791 00 ...
Page 10: ...viii z OS V1R1 0 TSO E REXX User s Guide ...
Page 12: ...x z OS V1R1 0 TSO E REXX User s Guide ...
Page 14: ...xii z OS V1R1 0 TSO E REXX User s Guide ...
Page 18: ...xvi z OS V1R1 0 TSO E REXX User s Guide ...
Page 20: ...2 z OS V1R1 0 TSO E REXX User s Guide ...
Page 58: ...Tracing Expressions with the TRACE Instruction 40 z OS V1R1 0 TSO E REXX User s Guide ...
Page 78: ...60 z OS V1R1 0 TSO E REXX User s Guide ...
Page 86: ...Built In Functions 68 z OS V1R1 0 TSO E REXX User s Guide ...
Page 128: ...Issuing Other Types of Commands from an Exec 110 z OS V1R1 0 TSO E REXX User s Guide ...
Page 136: ...Debugging Execs 118 z OS V1R1 0 TSO E REXX User s Guide ...
Page 170: ...Protecting Elements in the Data Stack 152 z OS V1R1 0 TSO E REXX User s Guide ...
Page 201: ...Part 3 Appendixes Copyright IBM Corp 1988 2001 183 ...
Page 202: ...184 z OS V1R1 0 TSO E REXX User s Guide ...
Page 222: ...Using Variables 204 z OS V1R1 0 TSO E REXX User s Guide ...
Page 226: ...208 z OS V1R1 0 TSO E REXX User s Guide ...
Page 238: ...220 z OS V1R1 0 TSO E REXX User s Guide ...
Page 241: ......