Exercises - Combining Loops

Procedure

  1. What happens when the following program runs?
    DO outer = 1 TO 3
      SAY                   /* Produces a blank line */
      DO inner = 1 TO 3
        SAY 'Outer' outer 'Inner' inner
      END
    END
  2. Now what happens when the LEAVE instruction is added?
    DO outer = 1 TO 3
      SAY                   /* Produces a blank line */
      DO inner = 1 TO 3
        IF inner = 2 THEN
          LEAVE inner
        ELSE
          SAY 'Outer' outer 'Inner' inner
      END
    END

Results

ANSWERS
  1. When this example runs, it produces 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

Task Task

Feedback


Timestamp icon Last updated: Tuesday, 7 January 2014


http://pic.dhe.ibm.com/infocenter/cicsts/v5r1/topic/com.ibm.cics.rexx.doc//dfhrx/dfhrx00050.html