There are five simple conditions:
A simple condition has a truth value of either true or false.
The class condition determines whether the content of a data item is alphabetic, alphabetic-lower, alphabetic-upper, numeric, or contains only the characters in the set of characters specified by the CLASS clause as defined in the SPECIAL-NAMES paragraph of the Environment Division.
Class Condition - Format
>>-identifier--+----+--+-----+--+-NUMERIC----------+-----------><
'-IS-' '-NOT-' +-ALPHABETIC-------+
+-ALPHABETIC-LOWER-+
+-ALPHABETIC-UPPER-+
| (1) |
+-DBCS-------------+
| (1) |
+-KANJI------------+
'-class-name-------'
Notes:
If identifier is a function identifier, it must reference an alphanumeric, DBCS, or date-time function.
with or without an operational sign.
If its PICTURE does not contain an operational sign, the item being tested is determined to be numeric only if the contents are numeric and an operational sign is not present.
If its PICTURE does contain an operational sign, the item being tested is determined to be numeric only if the item is an elementary item, the contents are numeric, and a valid operational sign is present.
In the EBCDIC character set, valid embedded operational positive signs are hexadecimal F, C, E, and A. Negative signs are hexadecimal D and B. The preferred positive sign is hexadecimal F, and the preferred negative sign is hexadecimal D. For items described with the SIGN IS SEPARATE clause, valid operational signs are + (hex 4E) and - (hex 60).
+-------------------------------IBM Extension--------------------------------+
For numeric and date-time data items, the identifier being tested can be described implicitly or explicitly as USAGE DISPLAY, USAGE PACKED-DECIMAL, USAGE COMP, or USAGE COMP-3.
+----------------------------End of IBM Extension----------------------------+
The class-name test must not be used with an identifier described as numeric.
+-------------------------------IBM Extension--------------------------------+
+----------------------------End of IBM Extension----------------------------+
The class test is not valid for items whose usage is INDEX, POINTER, or PROCEDURE-POINTER because these items do not belong to any class or category.
+-------------------------------IBM Extension--------------------------------+
The class condition cannot be used for external floating-point (USAGE DISPLAY) or internal floating-point (USAGE COMP-1 and USAGE COMP-2) items.
+----------------------------End of IBM Extension----------------------------+
Table 20 shows valid forms of the class test.
Table 20. Valid Forms of the Class Test
| Type of Identifier | Valid Forms of the Class Test | |
|---|---|---|
|
Alphabetic |
ALPHABETIC ALPHABETIC-LOWER ALPHABETIC-UPPER class-name |
NOT ALPHABETIC NOT ALPHABETIC-LOWER NOT ALPHABETIC-UPPER NOT class-name |
|
Alphanumeric, Alphanumeric-edited, or Numeric-edited |
ALPHABETIC ALPHABETIC-LOWER ALPHABETIC-UPPER NUMERIC class-name |
NOT ALPHABETIC NOT ALPHABETIC-LOWER NOT ALPHABETIC-UPPER NOT NUMERIC NOT class-name |
|
External-Decimal Internal-Decimal |
NUMERIC |
NOT NUMERIC |
+-------------------------------IBM Extension--------------------------------+
+----------------------------End of IBM Extension----------------------------+
|
DBCS KANJI |
NOT DBCS NOT KANJI |
+-------------------------------IBM Extension--------------------------------+
+----------------------------End of IBM Extension----------------------------+
|
NUMERIC class-name |
NOT NUMERIC NOT class-name |
A condition-name condition tests a conditional variable to determine whether its value is equal to any value(s) associated with the condition-name.
Condition-Name Condition - Format >>-condition-name----------------------------------------------><
A condition-name is used in conditions as an abbreviation for the relation condition. The rules for comparing a conditional variable with a condition-name value are the same as those specified for relation conditions.
If the condition-name has been associated with a range of values (or with several ranges of values), the conditional variable is tested to determine whether or not its value falls within the range(s), including the end values. The result of the test is true if one of the values corresponding to the condition-name equals the value of its associated conditional variable.
+-------------------------------IBM Extension--------------------------------+
Condition-names with floating-point and DBCS values are allowed.
+----------------------------End of IBM Extension----------------------------+
The following example illustrates the use of conditional variables and condition-names:
01 NUMBER PIC 99.
88 FIVE VALUE 5.
88 ONE-DIGIT-EVEN VALUE 0, 2, 4, 6, 8
88 TWO-DIGIT-NUMBER VALUE 10 THRU 99
NUMBER is the conditional variable; FIVE, ONE-DIGIT-EVEN, TWO-DIGIT-NUMBER are condition-names.
The following IF statements can be added to the above example to determine the age group of a specific record:
IF FIVE... (Tests for value 5) IF ONE-DIGIT-EVEN (Tests for values 0, 2, 4, 6, 8) IF TWO-DIGIT-NUMBER (Tests for values 10 thru 99)
Depending on the evaluation of the condition-name condition, alternative paths of execution are taken by the object program.
A relation condition compares two operands, either of which may be an identifier, a literal, an arithmetic expression, index-name or a function-identifier. The relation condition must contain at least one reference to an identifier.
Relation Condition - Format
>>-operand-1--+----+--+----------+------------------------------>
'-IS-' | (1) |
'-NOT------'
>--+-+-GREATER--+------+-+---------------+--operand-2----------><
| | '-THAN-' | |
| +->-----------------+ |
| +-LESS--+------+----+ |
| | '-THAN-' | |
| +-<-----------------+ |
| +-EQUAL--+----+-----+ |
| | '-TO-' | |
| '-=-----------------' |
+-GREATER--+------+--OR EQUAL--+----+-+
| '-THAN-' '-TO-' |
+->=----------------------------------+
+-LESS--+------+--OR EQUAL--+----+----+
| '-THAN-' '-TO-' |
'-<=----------------------------------'
Notes:
The relational operator specifies the type of comparison to be made. Each relational operator must be preceded and followed by a space.
+-------------------------------IBM Extension--------------------------------+
+----------------------------End of IBM Extension----------------------------+
Related Information:
+-------------------------------IBM Extension--------------------------------+
DBCS data items and literals can be used with all relational operators. Comparisons (between two DBCS items only) are based on the binary collating sequence of the hexadecimal values of the DBCS characters. If the items are not of the same length, the smaller item is padded with DBCS spaces to the right.
+----------------------------End of IBM Extension----------------------------+
+-------------------------------IBM Extension--------------------------------+
Pointer data items are items defined explicitly as USAGE IS POINTER. Otherwise, they are ADDRESS OF data items or ADDRESS OF special registers, which are implicitly defined as USAGE IS POINTER.
Only EQUAL and NOT EQUAL are allowed as relational operators when you specify pointer data items. The operands are equal if the two addresses used in the comparison would both result in the same storage location.
This relation condition is allowed in IF, PERFORM, EVALUATE, and SEARCH Format 1 statements. It is not allowed in SEARCH Format 2 (SEARCH ALL) statements, because there is not a meaningful ordering that can be applied to pointer data items.
ADDRESS Comparison - Format
>>-+-ADDRESS OF--identifier-1-+--+----+--+-----+---------------->
+-identifier-2-------------+ '-IS-' '-NOT-'
+-NULL---------------------+
'-NULLS--------------------'
>--+-EQUAL--+----+-+--+-ADDRESS OF--identifier-3-+-------------><
| '-TO-' | +-identifier-4-------------+
'-=-------------' +-NULL---------------------+
'-NULLS--------------------'
That is, NULL=NULL is not allowed.
+----------------------------End of IBM Extension----------------------------+
+-------------------------------IBM Extension--------------------------------+
Procedure-pointer data items are items defined explicitly as USAGE IS PROCEDURE-POINTER.
Only EQUAL and NOT EQUAL are allowed as relational operators when you specify procedure-pointer data items. The operands are equal if the two addresses used in the comparison would both result in the same storage location.
This relation condition is allowed in IF, PERFORM, EVALUATE, and SEARCH Format 1 statements. It is not allowed in SEARCH Format 2 (SEARCH ALL) statements, because there is not a meaningful ordering that can be applied to procedure-pointer data items.
Procedure-Pointer Comparison - Format >>-+-identifier-1-+--+----+--+-----+--+-EQUAL--+----+-+---------> +-NULL---------+ '-IS-' '-NOT-' | '-TO-' | '-NULLS--------' '-=-------------' >--+-identifier-2-+-------------------------------------------->< +-NULL---------+ '-NULLS--------'
+----------------------------End of IBM Extension----------------------------+
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.