Avaya Logo

Previous Topic

Next Topic

Book Contents

Book Index

strcmp

The strcmp instruction compares two character strings.

Synopsis

strcmp(ctype.src,ctype.src [,type.len ])

Description

The strcmp instruction compares two character strings and returns the result of the comparison in register 0 (that is, r.0). The return value is interpreted as follows:

If r.0 is:

=0

The strings are equal.

<0

The first string is lexicographically less than the second string.

>0

The first string is lexicographically greater than the second string.

The ctype.src argument can be either an address or a literal string. If the optional type.len argument is used, the comparison is limited to the number of characters specified by the argument.

Examples

In the following example, strcmp compares the literal string XYZ?:136 to the string in location char.20. If they are equal (exactly the same) the script jumps to the label equal.

strcmp("XYZ?:136",char.20)
jmp(r.0 ==0,equal)

In the following example, the string stored at location int.56 is compared to the string located at char.80. If the first string is greater or equal to the second (that is, would be listed after the string at char.80 in an alphabetical listing or is exactly the same as char.80), the script jumps to the label greg.

strcmp(int.56,char.80)
jmp(r.0 >= 0,greg)

© 2006 Avaya Inc. All Rights Reserved.