Added: CompareText/SameText variants
This commit is contained in:
parent
4d7c80a247
commit
e44bcd3706
@ -14,6 +14,22 @@ interface
|
|||||||
//:: unit will be chosen (KB, MB, GB).
|
//:: unit will be chosen (KB, MB, GB).
|
||||||
function FormatSize(const Bytes: Int64; KeepBytes: Boolean = False): String;
|
function FormatSize(const Bytes: Int64; KeepBytes: Boolean = False): String;
|
||||||
|
|
||||||
|
//:$ Compares two strings by ordinal value without case sensitivity up to
|
||||||
|
//:$ ALength characters.
|
||||||
|
function CompareTextL(const AMatch, AAgainst: String;
|
||||||
|
const ALength: Integer): Integer;
|
||||||
|
|
||||||
|
//:$ Compares two strings by ordinal value without case sensitivity up to
|
||||||
|
//:$ ALength characters.
|
||||||
|
function SameTextL(const AMatch, AAgainst: String;
|
||||||
|
const ALength: Integer): Boolean;
|
||||||
|
|
||||||
|
//:$ Compares AMatch against AAgainst using AAgainst's length.
|
||||||
|
function CompareTextS(const AMatch, AAgainst: String): Integer;
|
||||||
|
|
||||||
|
//:$ Compares AMatch against AAgainst using AAgainst's length.
|
||||||
|
function SameTextS(const AMatch, AAgainst: String): Boolean;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
uses
|
uses
|
||||||
SysUtils;
|
SysUtils;
|
||||||
@ -50,4 +66,40 @@ begin
|
|||||||
Result := FormatFloat(',0.##', dSize) + sExt;
|
Result := FormatFloat(',0.##', dSize) + sExt;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function CompareTextL;
|
||||||
|
var
|
||||||
|
sMatch: String;
|
||||||
|
sAgainst: String;
|
||||||
|
|
||||||
|
begin
|
||||||
|
// If there is no reason to copy; don't.
|
||||||
|
if Length(AMatch) <= ALength then
|
||||||
|
sMatch := AMatch
|
||||||
|
else
|
||||||
|
sMatch := Copy(AMatch, 1, ALength);
|
||||||
|
|
||||||
|
if Length(AAgainst) <= ALength then
|
||||||
|
sAgainst := AAgainst
|
||||||
|
else
|
||||||
|
sAgainst := Copy(AAgainst, 1, ALength);
|
||||||
|
|
||||||
|
Result := CompareText(sMatch, sAgainst);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function SameTextL;
|
||||||
|
begin
|
||||||
|
Result := (CompareTextL(AMatch, AAgainst, ALength) = 0);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function CompareTextS;
|
||||||
|
begin
|
||||||
|
Result := CompareTextL(AMatch, AAgainst, Length(AAgainst));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function SameTextS;
|
||||||
|
begin
|
||||||
|
Result := SameTextL(AMatch, AAgainst, Length(AAgainst));
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user