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:

 

 

[label]

CMATCH

{source}{sep}{dest}

 

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:

  1. 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.

  2. If the two characters are equal, the EQUAL (or ZERO) Condition Flag is set.

  3. 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.
     

  4. If either operand is a Null String, the EOS Condition Flag is set.

  5. 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:

 

  

CMATCH

SENDING TO RECV(X)

 

 

Variable

PL

FP

LP

Contents

Before:

SENDING

10

1

5

ABCDE·····

 

RECV(X)

8

6

6

FEDCBA··

 

After:

Both variables remain unchanged.

 

The EQUAL (or ZERO) Condition Flag is set.

 

Example 2:

 

 

Variable

PL

FP

LP

Contents

Before:

SENDING

10

4

5

ABCDE·····

 

RECV(X)

8

2

6

FEDCBA··

 

After:

Both variables remain unchanged.

 

No Condition Flags are set (all FALSE). The destination character (E) is neither equal nor less than the source character (D).

 

Example 3:

 

 

Variable

PL

FP

LP

Contents

Before:

SENDING

10

3

5

ABCDE·····

 

RECV(X)

8

5

6

FEDCBA··

 

After:

Both variables remain unchanged.

 

The LESS Condition Flag is set. The destination character (B) is less than the source character (C).

 

Example 4:

 

  

CMATCH

RECVING to "E"

 

 

Variable

PL

FP

LP

Contents

Before:

RECVING

8

2

6

FEDCBA··

 

After:

RECVING remains unchanged.

 

The EQUAL (or ZERO) Condition Flag is set.

 

Example 5:

 

  

CMATCH

0107 TO RECVING

 

 

Variable

PL

FP

LP

Contents

Before:

RECVING

8

1

6

FEDCBA··

 

After:

RECVING remains unchanged.

 

The LESS Condition Flag is set. The octal 0107 represents the letter `G'.

 

Example 6:

 

  

CMATCH

"#" TO RECV

 

 

Variable

PL

FP

LP

Contents

Before:

RECV

10

3

5

AB#CDE·····

 

After:

RECV remain unchanged.

 

The EQUAL (or ZERO) Condition Flag is set.

 

 

See Also: MATCH, Character String Instructions

 



PL/B Language Reference CLEAR CMOVE