SELECT (Begin a Select Group)

Free-Form Syntax SELECT
Code Factor 1 Factor 2 Result Field Indicators
SELECT

The select group conditionally processes one of several alternative sequences of operations. It consists of:

After the SELECT operation, control passes to the statement following the first WHENxx condition that is satisfied. All statements are then executed until the next WHENxx operation. Control passes to the ENDSL statement (only one WHENxx is executed). If no WHENxx condition is satisfied and an OTHER operation is specified, control passes to the statement following the OTHER operation. If no WHENxx condition is satisfied and no OTHER operation is specified, control transfers to the statement following the ENDSL operation of the select group.

Conditioning indicators can be used on the SELECT operation. If they are not satisfied, control passes immediately to the statement following the ENDSL operation of the select group. Conditioning indicators cannot be used on WHENxx, WHEN, OTHER and ENDSL operation individually.

The select group can be specified anywhere in calculations. It can be nested within IF, DO, or other select groups. The IF and DO groups can be nested within select groups.

If a SELECT operation is specified inside a select group, the WHENxx and OTHER operations apply to the new select group until an ENDSL is specified.

For more information, see Structured Programming Operations.

Figure 376. SELECT Operation
*...1....+....2....+....3....+....4....+....5....+....6....+....7...+....
CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq....
 *
 * In the following example, if X equals 1, do the operations in
 * sequence 1 (note that no END operation is needed before the
 * next WHENxx); if X does NOT equal 1, and if Y=2 and X<10, do the
 * operations in sequence 2.  If neither condition is true, do
 * the operations in sequence 3.
 *
C                   SELECT
C                   WHEN      X = 1
C                   Z-ADD     A             B
C                   MOVE      C             D
 *  Sequence 1
C                   :
C                   WHEN      ((Y = 2) AND (X < 10))
 *  Sequence 2
C                   :
C                   OTHER
 *  Sequence 3
C                   :
C                   ENDSL
 *
 * The following example shows a select group with conditioning
 * indicators.  After the CHAIN operation, if indicator 10 is on,
 * then control passes to the ADD operation.  If indicator 10 is
 * off, then the select group is processed.
 *
C     KEY           CHAIN     FILE                               10
C  N10              SELECT
C                   WHEN      X = 1
 *  Sequence 1
C                   :
C                   WHEN      Y = 2
 *  Sequence 2
C                   :
C                   ENDSL
C                   ADD       1              N


[ Top of Page | Previous Page | Next Page | Contents | Index ]