自由形式構文 | (許可されていない - WHEN 命令コードを使用) |
コード | 演算項目 1 | 演算項目 2 | 結果フィールド | 標識 | ||
---|---|---|---|---|---|---|
WHENxx | 被比較値 | 被比較値 |
選択グループの WHENxx 命令は、SELECT (選択グループの始め)命令が処理 された後でどこに制御を渡すかを決定します。
WHENxx 条件付き命令は、演算項目 1 と演算項目 2 に xx に よって指定された関係がある場合に真となります。条件が真の場合には、WHENxx の 後の命令が、 次の WHENxx、OTHER、ENDSL、 または END 命令まで処理されます。
WHENxx 命令を実行する場合には、次のことに留意してください。
xx に使用できる値については、比較命令を参照してください。
詳細については、構造化プログラミング命令を参照してください。
*...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
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.