StrCmp

Compares two strings.

Syntax:

StrCmp (string1, string2)

Parameters:

(s) string1, string2 strings to compare.

Returns:

(i)  -1, 0, or 1; depending on whether string1 is less than, equal to, or greater than string2, respectively.

 

Use this command to determine whether two strings are equal, or which precedes the other in an ANSI sorting sequence.

StriCmp is functionally the same as Binary Relational Operators.

When a string comparison is made, the lengths of the strings are ignored. Instead, the comparison begins with the first character of each string. If the first characters of each match, the next characters of each are compared, continuing until a mismatch is found. The rules for string matches made using the Binary Relational Operators are:

Example:


a = AskLine("STRCMP", "Enter a test line", "", 0)
b = AskLine("STRCMP", "Enter another test line", "", 0)
c = StrCmp(a, b)
c = c + 1
d = StrSub("less than equal to greater than", (c * 12)+ 1, 12)
; Note that above string is grouped into 12-character chunks.
; Desired chunk is removed with the StrSub statement.
Message("STRCMP", "%a% is %d% %b%")
See Also:

StriCmp, StrIndex, StrInsert, StrLen, StrOverlay, StrScan, StrSub