From Clomosy Docs
ClomosyAdmin (talk | contribs) No edit summary |
ClomosyAdmin (talk | contribs) No edit summary |
||
| Line 48: | Line 48: | ||
<h2> See Also </h2> | <h2> See Also </h2> | ||
* [[System_Library#String_Functions | String Functions]] | * [[System_Library#String_Functions | String Functions]] | ||
{{#seo:|title=CompareStr Using in Clomosy - Clomosy Docs}} | |||
{{#seo:|description=Use the CompareStr function in Clomosy to compare two strings case-sensitively and get the comparison result.}} | {{#seo:|description=Use the CompareStr function in Clomosy to compare two strings case-sensitively and get the comparison result.}} | ||
Latest revision as of 14:07, 24 December 2024
function CompareStr(const S1, S2: string): Integer;
Compares two strings, with case sensitivity.
CompareStr compares S1 to S2, with case sensitivity. The return value is less than 0 if S1 is less than S2, 0 if S1 equals S2, or greater than 0 if S1 is greater than S2. The comparison operation is based on the 16-bit ordinal value of each character and is not affected by the current locale, when using the first CompareStr overloaded method.
Note: The AnsiCompareStr function should be used, which takes into account multi-byte strings and accented characters.
The return value is one of the following.
s1 < s2 : < 0
s1 = s2 : = 0
s1 > s2 : > 0
Example
var
initialValue,secondValue : String;
resultValue :Integer;
{
initialValue = 'Clomosy';
secondValue = 'Clomosy';
resultValue = CompareStr(initialValue, secondValue);
if (resultValue < 0) ShowMessage(initialValue+' < '+secondValue);
if (resultValue == 0) ShowMessage(initialValue+' = '+secondValue);
if (resultValue > 0) ShowMessage(initialValue+' > '+secondValue);
}
Output:
Clomosy = Clomosy