bdfs1m1j | Structured Programming Macros |
Use this macro group to control the choice among a number of different code
paths by a logical comparison. The SELECT macro group is similar to the
CASE macro group except that instead of using an arithmetic expression to
select an alternative clause, SELECT conditions are successively evaluated
until an alternative can be selected.
The SELECT macro group includes the following macros:
- SELECT
- WHEN
- OTHERW
- ENDSEL.
Format
- SELECT
- specifies the start of the SELECT structure.
- WHEN
- specifies the start of a selection.
- operand1
- is a symbol, a register enclosed in parentheses, or a literal that can be
used as the first operand on a compare or test under mask (TM)
instruction.
- operand2
- is a symbol or a register enclosed in parentheses that can be used as the
second operand on a compare or test under mask (TM) instruction.
- operator
- is one of the following relational operators:
- Operator
- Description
- EQ
- Equal
- =
- Equal
- NE
- Not equal
- ¬=
- Not equal
- LE
- Less than or equal
- <=
- Less than or equal
- LT
- Less than
- <
- Less than
- GE
- Greater than or equal
- >=
- Greater than or equal
- GT
- Greater than
- >
- Greater than
- Z
- Zeroes (or OFF)
- O
- Ones (or ON)
- M
- Mixed zeros and ones
- NZ
- Not zeros
- NO
- Not ones
- NM
- Not mixed.
- OR
- allows additional expressions to be evaluated on one WHEN
statement.
- |
- allows additional expressions to be evaluated on one WHEN
statement.
- code1
- is the code to process when the associated WHEN statement is true.
- OTHERW
- specifies the start of the code to process when all the previous WHEN
statements are false.
- code2
- is the code to process when the previous WHEN statements are false.
- ENDSEL
- ends the SELECT structure.
Entry Requirements
None.
Return Conditions
- If the conditional expression associated with a WHEN clause is true, the
code following the WHEN clause is processed until the next WHEN or OTHERW
clause in that SELECT macro is found.
- If the conditional expression is false in a particular WHEN macro
statement, control is passed to the next sequential WHEN macro or the OTHERW
macro if there are no more WHEN macros in the current SELECT structure.
- After the instructions following a particular WHEN or OTHERW macro
statement are processed, control is passed to the ENDSEL macro.
- If the conditional expression for more than one WHEN is true, only the
code following the first true WHEN is processed.
- The contents of all the user registers are preserved across this macro
call.
Programming Considerations
- The SELECT, WHEN, OTHERW, and ENDSEL macros can only be used with the
SELECT macro group.
- Each macro statement and assembler instruction must begin on a new
line in the application.
- A section of code (represented by code1, and so on) can consist
of any number of standard assembler instructions, including other SPMs or
assembler macros.
- Because the SPMs are assembler language macros, all symbols used with
the macros must be previously defined to the assembler. In addition,
for the TPF SPMs, you must declare the attributes of the symbols using the DCL
macro.
- You can specify a maximum of 39 operands with the WHEN macro.
- If you specify the OR parameter, if any of the expressions separated by
the OR parameter is true, the whole WHEN macro statement is true.
- The SELECT and ENDSEL sequence of macros can be nested up to a limit of
eight.
Examples
The following is an example of a SELECT macro group.
SELECT
WHEN EBW000,EQ,OPTION1
:
* Code to process
:
WHEN EBW000,EQ,OPTION2,OR,EBW000,EQ,OPTION3
:
* Code to process
:
OTHERW
:
* Code to process
:
ENDSEL
Related Macros