WHENxx (真の場合に選択)

自由形式構文 (許可されていない - WHEN 命令コードを使用)
コード 演算項目 1 演算項目 2 結果フィールド 標識
WHENxx 被比較値 被比較値        

選択グループの WHENxx 命令は、SELECT (選択グループの始め)命令が処理 された後でどこに制御を渡すかを決定します。

WHENxx 条件付き命令は、演算項目 1 と演算項目 2 に xx に よって指定された関係がある場合に真となります。条件が真の場合には、WHENxx の 後の命令が、 次の WHENxx、OTHERENDSL、 または END 命令まで処理されます。

WHENxx 命令を実行する場合には、次のことに留意してください。
  • この命令グループが処理された後で、ENDSL 命令の後のステートメントに 制御が渡されます。
  • 複雑な WHENxx 条件は、ANDxx およ び ORxx を使用してコーディングすることができます。 演算は、WHENxx、ANDxx、および ORxx 命令の組み合わせによって指定された条件が 真である場合に処理されます。
  • WHENxx は空にすることができます。
  • 合計演算の中では、制御レベルの指定 (7 から 8 桁目) は ブランクにするか、あるいはプログラムの該当するセクション内のステートメントを グループにまとめる L1-L9 標識、LR 標識、または L0 の指定を入れることができます。 制御レベルの指定は文書化のためだけのものです。条件付け標識の指定 (9 から 11 桁目) は使用できません。

xx に使用できる値については、比較命令を参照してください。

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

図 1. WHENxx 命令
*...1....+....2....+....3....+....4....+....5....+....6....+....7...+....
CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq....
 *
 * The following example shows nested SELECT groups.  The employee
 * type can be one of 'C' for casual, 'T' for retired, 'R' for
 * regular, and 'S' for student.  Depending on the employee type
 * (EmpTyp), the number of days off per year (Days) will vary.
 *
C                   SELECT
C     EmpTyp        WHENEQ    'C'
C     EmpTyp        OREQ      'T'
C                   Z-ADD     0             Days
C     EmpTyp        WHENEQ    'R'
 *
 * When the employee type is 'R', the days off depend also on the
 * number of years of employment.  The base number of days is 14.
 * For less than 2 years, no extra days are added.  Between 2 and
 * 5 years, 5 extra days are added.  Between 6 and 10 years, 10
 * extra days are added, and over 10 years, 20 extra days are added.
 *
C                   Z-ADD     14            Days
 * Nested select group.
C                   SELECT
C     Years         WHENLT    2
C     Years         WHENLE    5
C                   ADD       5             Days
C     Years         WHENLE    10
C                   ADD       10            Days
C                   OTHER
C                   ADD       20            Days
C                   ENDSL
 * End of nested select group.
C     EmpTyp        WHENEQ    'S'
C                   Z-ADD     5             Days
C                   ENDSL
 *--------------------------------------------------------------------
 * Example of a SELECT group with complex WHENxx expressions.  Assume
 * that a record and an action code have been entered by a user.
 * Select one of the following:
 *   - When F3 has been pressed, do subroutine QUIT.
 *   - When action code(Acode) A (add) was entered and the record
 *     does not exist (*IN50=1), write the record.
 *   - When action code A is entered, the record exists, and the
 *     active record code for the record is D (deleted); update
 *     the record with active rec code=A.  When action code D is
 *     entered, the record exists, and the action code in the
 *     record (AcRec) code is A; mark the record as deleted.
 *   - When action code is C (change), the record exists, and the
 *     action code in the record (AcRec) code is A; update the record.
 *   - Otherwise, do error processing.
 *--------------------------------------------------------------------
*...1....+....2....+....3....+....4....+....5....+....6....+....7...+....
CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq....
C     RSCDE         CHAIN     FILE                               50
C                   SELECT
C     *INKC         WHENEQ    *ON
C                   EXSR      QUIT
C     Acode         WHENEQ    'A'
C     *IN50         ANDEQ     *ON
C                   WRITE     REC
C     Acode         WHENEQ    'A'
C     *IN50         ANDEQ     *OFF
C     AcRec         ANDEQ     'D'
C     Acode         OREQ      'D'
C     *IN50         ANDEQ     *OFF
C     AcRec         ANDEQ     'A'
C                   MOVE      Acode         AcRec
C                   UPDATE    REC
C     Acode         WHENEQ    'C'
C     *IN50         ANDEQ     *OFF
C     AcRec         ANDEQ     'A'
C                   UPDATE    REC
C                   OTHER
C                   EXSR      ERROR
C                   ENDSL