ELSE
SAY 'HIP'
END
SAY 'HURRAH'
END
The result is as follows:
HIP
HURRAH
HIP
HURRAH
Exercises - Combining Loops
1. What happens when the following exec runs?
DO outer=1TO3
SAY /* Write a blank line */
DO inner=1TO3
SAY 'Outer' outer 'Inner' inner
END
END
2. Now what happens when the LEAVE instruction is added?
DO outer=1TO3
SAY /* Write a blank line */
DO inner=1TO3
IF inner = 2 THEN
LEAVE inner
ELSE
SAY 'Outer' outer 'Inner' inner
END
END
ANSWERS
1. When this example runs, you see on your screen the following:
Outer 1 Inner 1
Outer 1 Inner 2
Outer 1 Inner 3
Outer 2 Inner 1
Outer 2 Inner 2
Outer 2 Inner 3
Outer 3 Inner 1
Outer 3 Inner 2
Outer 3 Inner 3
2. The result is one line of output for each of the inner loops.
Outer 1 Inner 1
Outer 2 Inner 1
Outer 3 Inner 1
Using Interrupt Instructions
Instructions that interrupt the flow of an exec can cause the exec to:
v Terminate (EXIT)
v Skip to another part of the exec marked by a label (SIGNAL)
Using Looping Instructions
56
z/OS V1R1.0 TSO/E REXX User’s Guide