ITERATE
ELSE
SAY 'Number' count
END
This example results in a list of numbers from 1 to 10 with the exception of number
8.
Number 1
Number 2
Number 3
Number 4
Number 5
Number 6
Number 7
Number 9
Number 10
Exercises - Using Loops
1. What are the results of the following loops?
a.
DO digit = 1 TO 3
SAY digit
END
SAY 'Digit is now' digit
b.
DO count = 10 BY -2 TO 6
SAY count
END
SAY 'Count is now' count
c.
DO index = 10 TO 8
SAY 'Hup! Hup! Hup!'
END
SAY 'Index is now' index
2. Sometimes an infinite loop can occur when input to end the loop doesn’t match
what is expected. For instance, in the previous example using the “LEAVE
Instruction” on page 50, what happens when the user enters
Quit
and the PULL
instruction is changed to a PARSE PULL instruction?
PARSE PULL dataset_name
ANSWERS
1. The results of the repetitive loops are as follows:
a.
1
2
3
Digit is now 4
b.
10
8
6
Count is now 4
c.
(blank)
Index is now 10
2. The user would be unable to leave the loop because "Quit" is not equal to
"QUIT". In this case, omitting the PARSE keyword is preferred because
Using Looping Instructions
Chapter 4. Controlling the Flow Within an Exec
51
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: ......