TStringHelper.Compare

Compare 2 strings

Declaration

Source position: syshelph.inc line 67

public 
  class function Compare(const A: string; const B: string) : Integer
                        ;  Overload;  Static;
  class function Compare(const A: string; const B: string; 
                        IgnoreCase: Boolean) : Integer;  Overload;  Static;
  class function Compare(const A: string; const B: string; 
                        Options: TCompareOptions) : Integer;  Overload
                        ;  Static;
  class function Compare(const A: string; IndexA: SizeInt; 
                        const B: string; IndexB: SizeInt; ALen: SizeInt)
                         : Integer;  Overload;  Static;
  class function Compare(const A: string; IndexA: SizeInt; 
                        const B: string; IndexB: SizeInt; ALen: SizeInt; 
                        IgnoreCase: Boolean) : Integer;  Overload;  Static;
  class function Compare(const A: string; IndexA: SizeInt; 
                        const B: string; IndexB: SizeInt; ALen: SizeInt; 
                        Options: TCompareOptions) : Integer;  Overload
                        ;  Static;

Description

Compare compares strings A and B. It returns the following result:

0 if the strings are equal a negative number if A < B a positive number if A > B

The comparison can be influenced by using the appropriate overloaded version of the function.

If the IndexA and IndexB parameters are present, the comparison starts at character index IndexA and IndexB. The indexes are zero-based. If the ALen parameters is present, then only the first ALen characters are compared. If not enough characters are present in either A or B, the comparison will include only as much characters as are present. If IgnoreCase is present and used, it determines whether the comparison is done case-sensitively. This form is deprecated, it is recommended to use the AOptions parameter and to include coIgnoreCase. The AOptions argument can be used to specify additional options. See TCompareOption for a list of possible values in this set.

Errors

None.

See also

Name Description
TCompareOption How to compare strings
TStringHelper.CompareOrdinal Compare 2 strings byte for byte
TStringHelper.CompareTo Compare string to another