COMPARE

Compares two strings to determine if they are the same.
Note: COMPARE uses the sort order specified on the Environment group's <CHARACTERS> tag.

If one string is shorter than the other, Enrichment pads the shorter string with blanks for the comparison.

Syntax

COMPARE(string1,string2,[start,case,length])

Arguments

Argument Description Default
string1 The first string to compare. None
string2 The second string to compare. None
[start] A number greater than 0 that indicates the column in string1 and string2 at which to begin the comparison. 1
[case] One of the following to indicate whether case must match: I
I Ignore case.
C Case must match exactly.
[length] The number of characters in string1 and string2 to compare. 0 indicates to compare all characters after the start column in the longest of the two strings. 0

Results

Result Description
Return One of the following:
-1 string1 is less than string2.
0 string1 is equal to string2.
1 string1 is greater than string2.
%%RC One of the following:
-2 length is less than or equal to 0.
-1 start is less than or equal to 0.
0 No error.
1 start is greater than the length of string1 and/or string2.
%%RM A null string (‘’).
%%RV Always set to 0.

Examples

Function Call Return %%RC
COMPARE('Total: 34.45','TOTAL: 21.45 X',1,I,5) 0 0
COMPARE('Total: 21.45','TOTAL: 21.45 X',1,C,5) 1 0
COMPARE('Total: 21.45','TOTAL: 34.45 ',10,I,0) 0 0