DECIDE FOR |
FIRST
|
CONDITION
|
||
EVERY
|
||||
{WHEN
logical-condition
statement
}
|
||||
[WHEN ANY
statement
]
|
||||
[WHEN ALL
statement
]
|
||||
WHEN NONE
statement
|
||||
END-DECIDE |
This document covers the following topics:
For explanations of the symbols used in the syntax diagram, see Syntax Symbols.
Related Statements: DECIDE
ON
| IF
|
IF SELECTION
|
ON ERROR
Belongs to Function Group: Processing of Logical Conditions
The DECIDE FOR
statement is used to decide for one or more
actions depending on multiple conditions (cases).
Note:
If no action is to be performed under a certain condition,
you must specify the statement IGNORE
in the corresponding clause of
the DECIDE FOR
statement.
Syntax Element | Description |
---|---|
FIRST CONDITION |
Processing of First Condition Only:
Only the first true condition is to be processed. See also Example 1. |
EVERY CONDITION |
Processing of Every Condition:
Every true condition is to be processed. See also Example 2. |
WHEN
logical-condition
statement
|
Logical Condition(s) to be Processed:
With this clause, you specify the logical condition(s) to be processed. See the section Logical Condition Criteria in the Programming Guide. |
WHEN
ANY statement
|
WHEN ANY Clause:
With |
WHEN
ALL statement
|
WHEN ALL Clause:
With This clause is applicable only if |
WHEN
NONE statement
|
WHEN NONE Clause:
With |
END-DECIDE
|
End of DECIDE FOR Statement:
The Natural reserved word |
** Example 'DECEX1': DECIDE FOR (with FIRST option) ************************************************************************ DEFINE DATA LOCAL 1 #FUNCTION (A1) 1 #PARM (A1) END-DEFINE * INPUT #FUNCTION #PARM * DECIDE FOR FIRST CONDITION WHEN #FUNCTION = 'A' AND #PARM = 'X' WRITE 'Function A with parameter X selected.' WHEN #FUNCTION = 'B' AND #PARM = 'X' WRITE 'Function B with parameter X selected.' WHEN #FUNCTION = 'C' THRU 'D' WRITE 'Function C or D selected.' WHEN NONE REINPUT 'Please enter a valid function.' MARK *#FUNCTION END-DECIDE * END
#FUNCTION #PARM
#FUNCTION A #PARM Y Please enter a valid function.
** Example 'DECEX2': DECIDE FOR (with EVERY option) ************************************************************************ DEFINE DATA LOCAL 1 #FIELD1 (N5.4) END-DEFINE * INPUT #FIELD1 * DECIDE FOR EVERY CONDITION WHEN #FIELD1 >= 0 WRITE '#FIELD1 is positive or zero.' WHEN #FIELD1 <= 0 WRITE '#FIELD1 is negative or zero.' WHEN FRAC(#FIELD1) = 0 WRITE '#FIELD1 has no decimal digits.' WHEN ANY WRITE 'Any of the above conditions is true.' WHEN ALL WRITE '#FIELD1 is zero.' WHEN NONE IGNORE END-DECIDE * END
#FIELD1 42
Page 1 05-01-11 14:56:26 #FIELD1 is positive or zero. #FIELD1 has no decimal digits. Any of the above conditions is true.