String Expression Relation

<string expression relation>

──<string expression>──<string relational operator>────────────────────►
►─<string expression>──────────────────────────────────────────────────┤

The string expression relation compares two string expressions according to the collating sequence of the character type of the string expressions. Only string expressions of the same character type can be compared.

Two strings are equal only if the lengths of the two strings are equal and if every character in one string is equal to the corresponding character in the other string. Two null strings are equal.

One string is strictly greater than a second string only if at least one of the following conditions is true:

  • The leftmost character in the first string that is not equal to the corresponding character in the second string compares as greater than the corresponding character in the second string.

  • The length of the first string is greater than the length of the second string, and the two strings compare as equal for the length of the second string.

Whenever two string literals can be compared as two arithmetic primaries, they are so compared. For example, the following Boolean expression yields a value of FALSE, because the two quoted strings are treated as two arithmetic primaries:

"B" > "AA"

However, if the two string literals "B" and "AA" are assigned to two string variables T and S, respectively, then the following Boolean expression yields a value of TRUE, because the first character of T is greater than the first character of S:

T > S

For example, if a string S1 is assigned the value "AAB12+", then all of the following comparisons are TRUE:

S1 EQL TAKE(S1,6)
S1 NEQ HEAD(S1,ALPHA)
S1 GTR HEAD(S1,ALPHA)
S1 LSS DROP(S1,3)
S1 LSS DROP(S1,1)