RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TAbstractNamedVariants.CompareStrings Method

Compares two strings.

Pascal
function CompareStrings(const S1: string; const S2: string): Integer; virtual;
C++
virtual __fastcall int CompareStrings(const AnsiString S1, const AnsiString S2);

TAbstractNamedVariants calls CompareStrings internally to locate names in the list (for example, in the implementation of the Values property). Descendant classes can use this method to sort the list entries by name. 

S1 and S2 are the strings to compare. 

CompareStrings returns a value less than 0 if S1 < S2, 0 if S1 = S2, and a value greater than 0 if S1 > S2. 

In TAbstractNamedVariants, CompareStrings calls the AnsiCompareText function. This performs a locale-based case-insensitive comparison. Override this method in a descendant class to change the way the named Variants list compares names. For example, by changing CompareStrings to a case sensitive function, the Values property would distinguish two names that differed only in case. 

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!