The
compare function
compares the two strings expressions
string1 and
string2 character by character to determine the alphabetical (collating sequence) order of the strings. The strings are compared in a case-sensitive manner. The
compareNoCase function compares strings in a case-insensitive manner.
Note: When using the Original
logic version, if
string1 and
string2 are of different lengths, the function will pad the shorter string with blanks to carry out the comparison. For example,
compare("a", "a ") returns 0, whereas it returns -1 when using logic version CSPro 8.0+.
The function returns an integer value of:
-1 | if string1 would be listed alphabetically before string2. |
0 | if the strings are identical. |
1 | if string1 would be listed alphabetically after string2. |
Direct string comparisons can also be made. For example, the following code is permissible: