Purpose
Performs case-sensitive string comparisons. You can call this function from the MapBasic window in MapInfo Pro.
Syntax
StringCompare( string1, string2 )
string1 and string2 are string expressions.
Return Value
SmallInt: -1 if first string precedes second; 1 if first string follows second; zero if strings are equal.
Description
The StringCompare() function performs case-sensitive string comparisons. MapBasic string comparisons which use the "=" operator are case-insensitive. Thus, a comparison expression such as the following:
If "ABC" = "abc" Then
evaluates as TRUE, because string comparisons are case-insensitive.
The StringCompare() function performs a case-sensitive string comparison and returns an indication of how the strings compare.
Return value: | When: |
---|---|
-1 | first string precedes the second string, alphabetically |
0 | the two strings are equal |
1 | first string follows the second string, alphabetically |
Example
The function call StringCompare("ABC", "abc") returns a value of -1, since "A" precedes "a" in the set of character codes.
See Also:
Like() function, StringCompareIntl() function