Compares two strings.
StrCmp (string1, string2)
(s) string1, string2 strings to compare.
(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:
If every character matches exactly and the strings are the same length, the strings are reported as identical.
If every character matches until the last character of one string is reached but the other string has remaining characters, the longer string will be reported as larger.
If the mismatch is between two numeric characters, the string with the larger numeric character is reported as larger.
When two case-mismatched alphabetic characters are found—one uppercase and one lowercase—the string with the uppercase character is reported as larger (even though the ASCII character code for A is 65, or 41h, while the character code for a is 97, or 61h).
For mismatched nonalphabetic and nonnumeric characters, the ASCII character codes are used. Following the rules for alphabetic characters, the string with the lower character code is reported as the larger string. For example, "one apple#" is reported as less than "one apple$" because the character code for # is 35 (23h), one less than the character code for $ (36 or 24h).
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%")
StriCmp, StrIndex, StrInsert, StrLen, StrOverlay, StrScan, StrSub