From Clomosy Docs
(Created page with "The AnsiCompareStr function compares two string values for equality. This is the modern, native safe form of CompareStr. All Ansi commands support multibyte and accented characters.<br> It returns these values: initialValue < secondValue : -ve number initialValue = secondValue : 0 initialValue > secondValue : +ve number The comparison is not affected by length - it is carried out on a letter by letter basis. But a longer string is greater than a shorter, oth...") |
ClomosyAdmin (talk | contribs) No edit summary |
||
| (10 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert"> | |||
function AnsiCompareStr(const S1, S2: string):Integer; | |||
</div> | |||
Compares strings based on the current locale with case sensitivity.<br> | |||
AnsiCompareStr compares S1 to S2, with case sensitivity. The comparison operation is controlled by the current locale. The return value is one of the following. <br> | |||
<div class="alert alert-secondary" role="alert" data-bs-theme="light"> | |||
s1 < s2 : < 0<br> | |||
s1 = s2 : = 0<br> | |||
s1 > s2 : > 0<br> | |||
</div> | |||
<div class="alert alert-ligth border border-3 border-warning rounded-5 p-4 shadow-sm" role="alert"> | |||
<strong>Note:</strong> Most locales consider lowercase characters to be less than the corresponding uppercase characters. This is in contrast to ASCII order, in which lowercase characters are greater than uppercase characters. Thus, setting S1 to 'a' and S2 to 'A' causees AnsiCompareStr to return a value less than zero, while [[CompareStr]], with the same arguments, returns a value greater than zero. | |||
</div> | |||
The comparison is not affected by length - it is carried out on a letter by letter basis. But a longer string is greater than a shorter, otherwise matching string.<br> | The comparison is not affected by length - it is carried out on a letter by letter basis. But a longer string is greater than a shorter, otherwise matching string.<br> | ||
The comparison is case sensitive.<br> | The comparison is case sensitive.<br> | ||
''' | <b>Example</b><br> | ||
<pre> | |||
var | |||
initialValue,secondValue : String; | |||
resultValue :Integer; | |||
{ | |||
initialValue = 'Clomosy'; | |||
secondValue = 'Clomosy'; | |||
resultValue = AnsiCompareStr(initialValue, secondValue); | |||
if (resultValue < 0) ShowMessage(initialValue+' < '+secondValue); | |||
if (resultValue == 0) ShowMessage(initialValue+' = '+secondValue); | |||
if (resultValue > 0) ShowMessage(initialValue+' > '+secondValue); | |||
} | |||
</pre> | |||
<b>Output:</b> | |||
<div class="alert alert-success" role="alert" data-bs-theme="light"> | |||
Clomosy = Clomosy | |||
</div> | |||
<h2> See Also </h2> | |||
* [[System_Library#String_Functions | String Functions]] | |||
{{#seo:|title=AnsiCompareStr Using in Clomosy - Clomosy Docs}} | |||
{{#seo:|description=AnsiCompareStr compares two strings with case sensitivity based on the current locale, returning a value to indicate their relative order.}} | |||
Latest revision as of 14:05, 24 December 2024
function AnsiCompareStr(const S1, S2: string):Integer;
Compares strings based on the current locale with case sensitivity.
AnsiCompareStr compares S1 to S2, with case sensitivity. The comparison operation is controlled by the current locale. The return value is one of the following.
s1 < s2 : < 0
s1 = s2 : = 0
s1 > s2 : > 0
Note: Most locales consider lowercase characters to be less than the corresponding uppercase characters. This is in contrast to ASCII order, in which lowercase characters are greater than uppercase characters. Thus, setting S1 to 'a' and S2 to 'A' causees AnsiCompareStr to return a value less than zero, while CompareStr, with the same arguments, returns a value greater than zero.
The comparison is not affected by length - it is carried out on a letter by letter basis. But a longer string is greater than a shorter, otherwise matching string.
The comparison is case sensitive.
Example
var
initialValue,secondValue : String;
resultValue :Integer;
{
initialValue = 'Clomosy';
secondValue = 'Clomosy';
resultValue = AnsiCompareStr(initialValue, secondValue);
if (resultValue < 0) ShowMessage(initialValue+' < '+secondValue);
if (resultValue == 0) ShowMessage(initialValue+' = '+secondValue);
if (resultValue > 0) ShowMessage(initialValue+' > '+secondValue);
}
Output:
Clomosy = Clomosy