LEAVE (Do/For グループからの抜け出し)
自由形式構文 | LEAVE |
コード | 演算項目 1 | 演算項目 2 | 結果フィールド | 標識 | ||
---|---|---|---|---|---|---|
LEAVE |
LEAVE 命令は、DO または FOR グループの中から ENDDO または ENDFOR 命令の後のステートメントに制御を渡します。
LEAVE は、DO、DOU、DOUxx、DOW、DOWxx、または FOR ループの中で、一番内側のループから、一番内側のループの ENDDO または ENDFOR 命令の後のステートメントにただちに制御を渡すために使用できます。DO または FOR グループから抜けるために LEAVE を使用しても指標の増分は行われません。
ネストされたループでは、LEAVE によって 1 レベルだけ “外側” へ 制御が渡されます。 DO または FOR グループの外側では LEAVE は使用できません。
ITER (繰り返し)命令は LEAVE 命令に似ていますが、ITER は ENDDO または ENDFOR ステートメントに 制御を渡します。
詳細については、分岐命令または 構造化プログラミング命令を参照してください。
図 1. LEAVE 命令
*...1....+....2....+....3....+....4....+....5....+....6....+....7....+....
CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq....
*
* The following example uses an infinite loop. When the user
* types 'q', control transfers to the LEAVE operation, which in
* turn transfers control out of the loop to the Z-ADD operation.
*
C 2 DOWNE 1
C :
C IF ANSWER = 'q'
C LEAVE
C ENDIF
C :
C ENDDO
C Z-ADD A B
*
* The following example uses a DOUxx loop containing a DOWxx.
* The IF statement checks indicator 1. If it is ON, indicator
* 99 is turned ON, control passes to the LEAVE operation and
* out of the inner DOWxx loop.
*
* A second LEAVE instruction is then executed because indicator 99
* is ON, which in turn transfers control out of the DOUxx loop.
*
C :
C FLDA DOUEQ FLDB
C NUM DOWLT 10
C *IN01 IFEQ *ON
C SETON 99
C LEAVE
C :
C ENDIF
C ENDDO
C 99 LEAVE
C :
C ENDDO
C :