ITER (繰り返し)

自由形式構文 ITER
コード 演算項目 1 演算項目 2 結果フィールド 標識
ITER            

ITER 命令は、DO または FOR グループの中からそのグループの ENDDO または ENDFOR ステートメントに制御を渡します。この命令は、DO、DOU、DOUxx、 DOW、DOWxx、および FOR ループ内で、ループの ENDDO または ENDFOR ステートメントにただちに制御を渡すために使用できます。ITER 命令によって、ループの次の繰り返しが直ちに実行されます。 ITER は一番内側のループに影響を与えます。

制御が渡される ENDDO または ENDFOR ステートメントに条件付け標識があってその条件が満たされない場合には、その ENDDO または ENDFOR 命令の後のステートメントから処理が続行されます。

LEAVE (Do/For グループからの抜け出し)命令は ITER 命令に似ていますが、LEAVE は、ENDDO または ENDFOR 命令の次の ステートメントに制御を渡します。

詳細については、分岐命令または 構造化プログラミング命令を参照してください。

図 1. ITER 命令
*...1....+....2....+....3....+....4....+....5....+....6....+....7....+....
CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq....
 *
 * The following example uses a DOU loop containing a DOW loop.
 * The IF statement checks indicator 01.  If indicator 01 is ON,
 * the LEAVE operation is executed, transferring control out of
 * the innermost DOW loop to the Z-ADD instruction.  If indicator
 * 01 is not ON, subroutine PROC1 is processed.  Then indicator
 * 12 is checked.  If it is OFF, ITER transfers control to the
 * innermost ENDDO and the condition on the DOW is evaluated
 * again.  If indicator 12 is ON, subroutine PROC2 is processed.
C
C                   DOU       FLDA = FLDB
C                   :
C     NUM           DOWLT     10
C                   IF        *IN01
C                   LEAVE
C                   ENDIF
C                   EXSR      PROC1
C     *IN12         IFEQ      *OFF
C                   ITER
C                   ENDIF
C                   EXSR      PROC2
C                   ENDDO
C                   Z-ADD     20            RSLT              2 0
C                   :
C                   ENDDO
C                   :
*...1....+....2....+....3....+....4....+....5....+....6....+....7....+....
CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq....
 *
 * The following example uses a DOU loop containing a DOW loop.
 * The IF statement checks indicator 1. If indicator 1 is ON, the
 * MOVE operation is executed, followed by the LEAVE operation,
 * transferring control from the innermost DOW loop to the Z-ADD
 * instruction.  If indicator 1 is not ON, ITER transfers control
 * to the innermost ENDDO and the condition on the DOW is
 * evaluated again.
C                   :
C     FLDA          DOUEQ     FLDB
C                   :
C     NUM           DOWLT     10
C     *IN01         IFEQ      *ON
C                   MOVE      'UPDATE'      FIELD            20
C                   LEAVE
C                   ELSE
C                   ITER
C                   ENDIF
C                   ENDDO
C                   Z-ADD     20            RSLT              2 0
C                   :
C                   ENDDO
C                   :