NET/MASTER Network Control Language (NCL) Reference Manual

COMPARE
Built-in Functions
4–30 106126 Tandem Computers Incorporated
COMPARE The COMPARE built-in function compares two strings and returns the numerical
position of the first differing character. The shorter string is padded with the pad
character to make both strings equal in length.
If the strings are identical, 0 (zero) is returned.
COMPARE(
string1
,
string2
[,
pad
] )
string1
specifies the first string.
string2
specifies the second string, which is compared with
string1
.
pad
specifies the character to be used to pad the shorter string. If omitted, a space is
used.
Consideration
See also ABBREV, which tests a string to see if it starts with a particular set of
characters.
Examples
In the following example, the strings “abc” and “abc” are compared. NCL returns a
value of 0 (zero) because the two strings are identical:
&A = abc
&B = abc
&RESULT = COMPARE(&A,&B)
In the following example, the strings “abc” and “az” are compared. NCL returns a
value of 2 because the strings differ at the second character:
SAY COMPARE(abc,az)
In the following example, the strings “abcgggggggh” and “abc” are compared and the
shorter string “abc” is padded with trailing “g” characters to make both strings the
same length. NCL returns a value of eleven (11) because the strings differ at the
eleventh character:
SAY COMPARE(abcgggggggh,abc,g)