SELECT
PLBCMP Only
The SELECT instruction provides a multi-way branch that allows a series of conditional statements to evaluate multiple conditions. The instruction uses the following format:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Where:
label
Optional. A Program Execution Label.
select1
Required. A Character Variable, Numeric Variable, an Expression, or a decimal constant value evaluated.
select2
Optional. An additional Character String Variable, Numeric Variable, an Expression, or a decimal constant value evaluated.
select10
Optional. An additional Character String Variable, Numeric Variable, an Expression, or a decimal constant value evaluated.
when1
Required. A Character String Variable, Numeric Variable, an Expression, or a decimal constant value matched or compared with the first operand in the SELECT statement.
when2
Optional. An additional Character String Variable, Numeric Variable, an Expression, or a decimal constant value matched or compared with the corresponding operand in the SELECT statement.
when10
Optional. An additional Character String Variable, Numeric Variable, an Expression or a decimal constant value matched or compared with the corresponding operand in the SELECT statement.
Flags Affected: NONE
Note the following:
The SELECT statement defines the beginning of the construct and requires one or more SELECT operands specified in the statement.
No executable statements are allowed between the SELECT and the first WHEN statement.
The ENDSELECT statement defines the end of the construct.
At least one WHEN statement must be specified between the SELECT and the ENDSELECT statements. Any number of additional WHEN statements may be used.
An optional DEFAULT statement may be specified after the last WHEN statement but before the ENDSELECT. Only one DEFAULT statement is allowed.
The SELECT may have up to ten (10) operands specified with a comma delimiter between each.
Each operand specified for the SELECT statement defines a selection criteria used when evaluating each WHEN statement.
Each WHEN statement operand is compared or matched to the corresponding SELECT operand defined.
The data type for a WHEN operand must be the same as the corresponding operand for the SELECT statement.
If all of the WHEN operands match or compare to all of the SELECT operands, the WHEN statement is determined to satisfy the selection criteria and the statements following the WHEN statement are executed. The statements for only one WHEN statement are executed when the selection criteria is determined to satisfy all operands.
Each WHEN statement operand may be specified as more than one selection criteria.
If a WHEN statement operand has more than one selection criteria and defines a range, the selection criteria items are separated by the keyword 'THRU'. This allows the matching condition to occur when the SELECT operand is determined within the range specified inclusive.
If a WHEN statement operand has more than one selection criteria item, the keyword 'OR' must separate the selection criteria items. In this case, either selection criteria item matching the corresponding SELECT operand may satisfy a matching condition.
If a WHEN operand is not specified, the corresponding SELECT operand is considered to match the NULL WHEN operand.
Nesting of the SELECT/WHEN/DEFAULT/ENDSELECT construct is allowed up to 32 levels.
See Also: Example Code, Program Control Instructions
![]() |