CMATCH
The CMATCH instruction compares a single character in the source string to a single character in the destination string. The instruction uses the following format:
|
|
|
|
|
Where:
label
Optional. A Program Execution Label.
source
Required. A previously defined Character String Variable, a National Character String Variable, a single character Literal, a National Character String Literal, a {ctrl} representation, or an EQUATEd value that is compared to the {dest} value.
sep
Required. A comma or one of the following prepositions: BY, TO, OF, FROM, USING, WITH, IN, or INTO.
dest
Required. A previously defined Character String Variable, a National Character String Variable, a single character Literal, a National Character String Literal, a {ctrl} representation, or an EQUATEd value that is compared to the {source} value.
Flags Affected: EOS, LESS, ZERO
Note the following:
The Form Pointed character in the source string or the character specified by {source} is compared to the Form Pointed character in the destination string or the literal specified by {dest}. The contents of both operands remain unchanged.
If the two characters are equal, the EQUAL (or ZERO) Condition Flag is set.
If the two characters are not equal, the instruction makes the following calculation
based on the hexadecimal value of the two characters
X = DESTINATION HEX VALUE - SOURCE HEX VALUE
If X is negative, the LESS Condition Flag is set.
If either operand is a Null String, the EOS Condition Flag is set.
Since CMATCH only accepts a single character literals, no forcing character is required or allowed in the literal. To match for a literal hash mark, use a single character literal parameter ("#").
Example 1:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ABCDE····· |
|
|
|
|
|
|
FEDCBA·· |
|
| |||||
|
|
| ||||
The EQUAL (or ZERO) Condition Flag is set.
Example 2:
|
|
|
|
|
|
|
|
|
|
|
|
|
ABCDE····· |
|
|
|
|
|
|
FEDCBA·· |
|
| |||||
|
|
| ||||
No Condition Flags are set (all FALSE). The destination character (E) is neither equal nor less than the source character (D).
Example 3:
|
|
|
|
|
|
|
|
|
|
|
|
|
ABCDE····· |
|
|
|
|
|
|
FEDCBA·· |
|
| |||||
|
|
| ||||
The LESS Condition Flag is set. The destination character (B) is less than the source character (C).
Example 4:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FEDCBA·· |
|
| |||||
|
|
| ||||
The EQUAL (or ZERO) Condition Flag is set.
Example 5:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FEDCBA·· |
|
| |||||
|
|
| ||||
The LESS Condition Flag is set. The octal 0107 represents the letter `G'.
Example 6:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AB#CDE····· |
|
| |||||
|
|
| ||||
The EQUAL (or ZERO) Condition Flag is set.
See Also: MATCH, Character String Instructions
![]() |