COMPARE


The COMPARE function compares two strings and returns a value indicating whether or not they are equal.

 

COMMAND SYNTAX

COMPARE(expression1, expression2{, justification})

 

SYNTAX ELEMENTS

expression1 is the first string for comparison
expression2 is the second string for comparison
justification specifies how the strings are to be compared. "L" indicates a left justified comparison. "R" indicates a right justified comparison. The default is left justification.

The function will return one of the following values:

-1 the first string is less than the second
0 the strings are equal
1 the first string is greater than the second

 

EXAMPLE

A = "XY999"
B = "XY1000"
R1 = COMPARE(A,B,"L")
R2 = COMPARE(A,B,"R")
CRT R1,R2

The code above displays 1 -1 which indicates that XY999 is greater than XY1000 in a left justified comparison and XY999 is less than XY1000 in a right justified comparison.

 

INTERNATIONAL MODE

When using the COMPARE function in International Mode, the function will use the currently configured locale to determine the rules by which each string is considered less than or greater than the other will.

 


jBC