MATCH
The MATCH instruction compares two character strings or two RECORDS. The instruction uses the following format:
|
|
|
|
|
Where:
label
Optional. A Program Execution Label.
source
Required. A previously defined Character String Variable, National Character String Variable, Literal, National Character String Literal, or RECORD that is compared to the {dest} operand.
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, National Character String Variable, Literal, National Character String Literal, or RECORD that is compared to the {source} operand.
wildcard
Required. A previously defined Character String Variable, National Character String Variable, or constant character indicating source variable wildcard characters.
Flags Affected: EOS, LESS, ZERO
Note the following:
Only the Logical String contents of the {source} and {dest} strings are compared.
None of the operands, nor their Form Pointers or Length Pointers change.
If either operand is a Null String, the LESS and EQUAL Condition Flags are not set (both FALSE) and the EOS Condition Flag is set.
The operand length is defined as:
LENGTH = Length Pointer - Form Pointer + 1
If all characters matched are equal, the EQUAL
(or ZERO) Condition Flag is
set. The instruction then makes the following calculation:
X = DESTINATION LOGICAL LENGTH - SOURCE LOGICAL LENGTH
If X is negative, the LESS Condition Flag is set.
If all characters compared are not equal, the instruction makes the following calculation
based on the hexadecimal value of the first non-matching character:
X = DESTINATION HEX VALUE - SOURCE HEX VALUE
If X is negative, the LESS Condition Flag is set.
The optional third parameter ({wildcard}) specifies a character that is treated as a don't care or wildcard character. If the specified character exists in the {source} operand, it matches any character in the destination operand that occupies the same relative position. If {wildcard} is a character string variable, the Form Pointed character is used.
If the operands are RECORDs, the MATCH operation is an absolute comparison of each byte in {source} to the corresponding byte in {dest}. The comparison is not being performed on a per member basis and therefore the {wildcard} parameter is not allowed. Specification of the {wildcard} parameter will produce a warning message by the compiler. The MATCH instruction does not support record pointers.
Example 1:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12345ABCDE·· |
|
|
|
|
|
|
ABCDE12345·· |
|
| |||||
|
|
| ||||
The EQUAL (or ZERO) Condition Flag is set.
Example 2:
|
|
|
|
|
|
|
|
|
|
|
|
|
12345ABCDE·· |
|
|
|
|
|
|
ABCDE12345·· |
|
| |||||
|
|
| ||||
The EQUAL (or ZERO) Condition Flag is set. The LESS Condition Flag is also set because the destination field is shorter than the source field.
Example 3:
|
|
|
|
|
|
|
|
|
|
|
|
|
12345ABCDE·· |
|
|
|
|
|
|
ABCDE12245·· |
|
| |||||
|
|
| ||||
The LESS Condition Flag is set.
Example 4:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12345ABCDE |
|
| |||||
|
|
| ||||
The LESS Condition Flag is set. The hexadecimal value of numeric characters is less than that of alphabetic characters.
Example 5:
|
|
|
|
|
|
|
|
|
|
|
|
|
12345ABCDE |
|
| |||||
|
|
| ||||
The EQUAL (or ZERO) Condition Flag is set. The source operand was shorter than the destination operand. Therefore, the LESS Condition Flag is not set (FALSE).
Example 6:
|
|
|
|
|
|
|
|
|
|
|
|
|
12345ABXXX |
|
| |||||
|
|
| ||||
No Condition Flags are set (all FALSE). The first non-matching source character (C) is less than the first non-matching destination character (X).
Example 7:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SM?TH·········· |
|
|
|
|
|
|
SMYTHE, JOHN A. ······ |
|
| |||||
|
|
| ||||
The EQUAL (or ZERO) Condition Flag is set.
Example 8:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SMITH·········· |
|
|
|
|
|
|
JOHN A. ············ |
|
|
|
|
|
|
SMITH·········· |
|
|
|
|
|
|
JOHN A. ············ |
|
| |||||
|
|
| ||||
The EQUAL (or ZERO) Condition Flag is set.
Example 9:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SMITH·········· |
|
|
|
|
|
|
JOHN A. ············ |
|
|
|
|
|
|
SMITH·········· |
|
|
|
|
|
|
JOHN A. ············ |
|
| |||||
|
|
| ||||
The EQUAL (or ZERO) Condition Flag is cleared. The Logical Length of the second field is shorter in the second record.
See Also: MATCHLIST, CMATCH, Character String Instructions
![]() |