Exercises - Using Loops - IBM TSO/E REXX User Manual

Table of Contents

Advertisement

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?
DO digit = 1 TO 3
a.
SAY digit
END
SAY 'Digit is now' digit
DO count = 10 BY -2 TO 6
b.
SAY count
END
SAY 'Count is now' count
DO index = 10 TO 8
c.
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

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents