z/OS TSO/E CLISTs
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Nesting loops

z/OS TSO/E CLISTs
SA32-0978-00

The action of a loop can contain other loops. Loops within loops are called nested loops. Loops can contain nested loops of the same type or of a different type.

Nested loops of the same type are often iterative DO-loops within other iterative DO-loops. For example, to execute 100 CLISTs named PROC00 through PROC99, you can code:
DO &I = 0 to 9
 DO &J = 0 to 9
  %proc&I&J
 END
END
Nested loops of a different type are often DO-UNTIL loops within DO-WHILE loops, for example:
SET &COUNTER1 = 0                /* Initialize outer loop counter      */
SET &COUNTER2 = 3                /* Initialize nested loop counter     */
DO WHILE &COUNTER1 <  5
 /* Perform action while &counter1 is less than 5                      */
⋮
  (action)                       /* Executes 5 times                   */
⋮
 DO UNTIL &COUNTER2 = 0
  /* Perform action until &counter2 is equal to 0                      */
⋮
  (Subset of action)             /* Executes 3 times                   */
⋮
  SET COUNTER2 = &COUNTER2 - 1   /* Increase nested loop counter by 1  */
 END
⋮
 SET COUNTER1 = &COUNTER1 + 1    /* Increase outer loop counter by 1   */
END

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014