Clib Compare Strings Method
The Clib Compare Strings method performs a comparison between two strings, one byte at a time. It returns one of the following values:
If the strings are identical, then it returns the following value:
0
If the ASCII code of the first unmatched character in the string1 argument is:
Less than that of the first unmatched character in the string2 argument, then it returns a negative number.
Greater than that of the first unmatched character in the string2 argument, then it returns a positive number.
It stops the comparison if one of the following situations occurs:
It encounters a mismatch between strings.
It encounters a terminating null byte.
Format
Clib.stricmp(string1, string2)
Clib.strcmpi(string1, string2)
Clib.strncmp(string1, string2, maxLen)
Clib.strncmpi(string1, string2, maxLen)
Clib.strnicmp(string1, string2, maxLen)
You can use one of the following:
Search that is case-sensitive. You use Clib.strncmp.
Search that is not case-sensitive. You use Clib.stricmp or Clib.strcmpi. In a comparison that is not case-sensitive, A and a are the same.
The Clib.strncmp, Clib.strncmpi, and Clib.strnicmp methods stop the comparison when one of the following situations occurs:
It has compared the number of bytes that you specify in the maxLen argument.
It encounters a terminating null byte.
The following table describes the arguments for the Clib Compare Strings method.
Argument | Description |
---|---|
string1 |
A string or a variable that contains a string that this method compares against the string that the string2 argument contains. |
string2 |
A string or a variable that contains a string that this method compares against the string that the string1 argument contains. |
maxLen |
The number of bytes to compare. |