From Clomosy Docs

No edit summary
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

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.



The return value is one of the following.

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:

See Also