uses StrUtils; [Abstract of string functions]
First function AnsiResemblesText(const AText, AOther: string): Boolean;
$[StrUtils.pas
Function returns whether the two strings are similar
Description ANSI (American National Standards Institute) American National Standards Institute; case-insensitive
Reference function StrUtils.SoundexPRoc; var StrUtils.AnsiResemblesProc
Example CheckBox1.Checked := AnsiResemblesText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
First function AnsiContainsText(const AText, ASubText: string): Boolean;
$[StrUtils.pas
Function returns whether the string AText contains a substring ASubText
Indicates case insensitive
Reference function StrUtils.AnsiUppercase; function StrUtils.Ansipos
Example CheckBox1.Checked := AnsiContainsText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
First function AnsiStartsText(const ASubText, AText: string): Boolean;
$[StrUtils.pas
Function returns whether the string AText starts with a substring ASubText
Indicates case insensitive
Reference function Windows.CompareString
Example CheckBox1.Checked := AnsiStartsText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
First function AnsiEndsText(const ASubText, AText: string): Boolean;
$[StrUtils.pas
Function returns whether the string AText ends with a substring ASubText
Indicates case insensitive
Reference function Windows.CompareString
Example CheckBox1.Checked := AnsiEndsText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
The first function AnsiReplaceText(const AText, AFromText, AToText: string):
string; $[StrUtils.pas
Function returns the result of replacing substring AFromText with substring AToText in the string AText
Indicates case insensitive
Reference function SysUtils.StringReplace; type SysUtils.TReplaceFlags
Example Edit4.Text := AnsiReplaceText(Edit1.Text, Edit2.Text, Edit3.Text);
━━━━━━━━━━━━━━━━━━━━━
First function AnsiMatchText(const AText: string; const AValues: array of
string): Boolean; $[StrUtils.pas
Function returns whether string AText is included in the string array AValues
Indicates case insensitive
Reference function StrUtils.AnsiIndexText
Example CheckBox1.Checked := AnsiMatchText(Edit1.Text, ['a1', 'a2', 'a3',
'a4']);
━━━━━━━━━━━━━━━━━━━━━
First function AnsiIndexText(const AText: string; const AValues: array of
string): Integer; $[StrUtils.pas
Function returns the position of the string AText in the string array AValues
Indicates that it is case-insensitive; if not included, return -1
Reference function SysUtils.AnsiSameText
Example SpinEdit1.Value := AnsiIndexText(Edit1.Text, ['a1', 'a2', 'a3', 'a4']);
━━━━━━━━━━━━━━━━━━━━━
First function AnsiContainsStr(const AText, ASubText: string): Boolean;
$[StrUtils.pas
Function returns whether the string AText contains a substring ASubText
Description case sensitive
Reference function StrUtils.AnsiPos
Example CheckBox1.Checked := AnsiContainsStr(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
First function AnsiStartsStr(const ASubText, AText: string): Boolean;
$[StrUtils.pas
Function returns whether the string AText starts with a substring ASubText
Description case sensitive
Reference function SysUtils.AnsiSameStr
Example CheckBox1.Checked := AnsiStartsStr(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
First function AnsiEndsStr(const ASubText, AText: string): Boolean;
$[StrUtils.pas
Function returns whether the string AText ends with a substring ASubText
Description case sensitive
Reference function SysUtils.AnsiSameStr
Example CheckBox1.Checked := AnsiEndsStr(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
The first function AnsiReplaceStr(const AText, AFromText, AToText: string):
string; $[StrUtils.pas
Function returns the result of replacing substring AFromText with substring AToText in the string AText
Description case sensitive
Reference function SysUtils.StringReplace; type SysUtils.TReplaceFlags
Example Edit4.Text := AnsiReplaceStr(Edit1.Text, Edit2.Text, Edit3.Text);
━━━━━━━━━━━━━━━━━━━━━
First function AnsiMatchStr(const AText: string; const AValues: array of
string): Boolean; $[StrUtils.pas
Function returns whether string AText is included in the string array AValues
Description case sensitive
Reference function StrUtils.AnsiIndexStr
Example CheckBox1.Checked := AnsiMatchStr(Edit1.Text, ['a1', 'a2', 'a3',
'a4']);
━━━━━━━━━━━━━━━━━━━━━
First function AnsiIndexStr(const AText: string; const AValues: array of
string): Integer; $[StrUtils.pas
Function returns the position of the string AText in the string array AValues
Description case sensitive
Reference function SysUtils.AnsiSameStr
Example SpinEdit1.Value := AnsiIndexStr(Edit1.Text, ['a1', 'a2', 'a3', 'a4']);
━━━━━━━━━━━━━━━━━━━━━
First function DupeString(const AText: string; ACount: Integer): string;
$[StrUtils.pas
Function returns ACount replicas of the string AText
Description Returns '' when ACount is 0
Refer to function System.SetLength
Example Edit3.Text := DupeString(Edit1.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
Header function ReverseString(const AText: string): string; $[StrUtils.pas
Function returns the inverse order of the string AText
Description ReverseString('1234') = '4321'
Refer to function System.SetLength
Example Edit3.Text := ReverseString(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
First function StuffString(const AText: string; AStart, ALength: Cardinal;
const ASubText: string): string; $[StrUtils.pas
Function returns nested strings
Description AStart: nesting start position; ALength: nesting length; StuffString('abcd', 2, 0, '12') = 'a12bcd'
Refer to function System.Copy
Example Edit3.Text := StuffString(Edit1.Text, SpinEdit1.Value, SpinEdit2.Value,
Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
First function RandomFrom(const AValues: array of string): string; overload;
$[StrUtils.pas
Function randomly returns an element in the string array AValues
Explain that it is recommended to execute Randomize before
Reference function System.Random
Example Randomize; Edit3.Text := RandomFrom(['a1', 'a2', 'a3', 'a4']);
━━━━━━━━━━━━━━━━━━━━━
Header function IfThen(AValue: Boolean; const ATrue: string; AFalse: string =
''): string; overload; $[StrUtils.pas
Function returns the specified logical string
IfThen(True, 'Yes', 'No') = 'Yes';IfThen(False, 'Yes', 'No') = 'No'
Reference <NULL>
Example Edit3.Text := IfThen(CheckBox1.Checked, Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
Header function LeftStr(const AText: string; const ACount: Integer): string;
$[StrUtils.pas
Function returns the ACount characters on the left side of the string AText
Description LeftStr('123456', 3) = '123'
Refer to function System.Copy
Example Edit3.Text := LeftStr(Edit1.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
First function RightStr(const AText: string; const ACount: Integer): string;
$[StrUtils.pas
Function returns the ACount characters on the right side of the string AText
Description RightStr('123456', 3) = '456'
Refer to function System.Copy
Example Edit3.Text := RightStr(Edit1.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
First function MidStr(const AText: string; const AStart, ACount: Integer):
string; $[StrUtils.pas
Function returns the string AText ACount characters starting from AStart
It means Copy
Refer to function System.Copy
Example Edit3.Text := MidStr(Edit1.Text, SpinEdit1.Value, SpinEdit2.Value);
━━━━━━━━━━━━━━━━━━━━━
First function SearchBuf(Buf: PChar; BufLen: Integer; SelStart, SelLength:
Integer; SearchString: String; Options: TStringSearchOptions = [soDown]):
PChar; $[StrUtils.pas
Function returns the first searched pointer position
Explain this function is often used to search strings in text
Reference <NULL>
example
//////////Begin SearchBuf
function SearchEdit(EditControl: TCustomEdit; const SearchString: String;
SearchOptions: TStringSearchOptions; FindFirst: Boolean = False): Boolean;
var
Buffer, P: PChar;
Size: Word;
Begin
Result := False;
if (Length(SearchString) = 0) then Exit;
Size := EditControl.GetTextLen;
if (Size = 0) then Exit;
Buffer := StrAlloc(Size + 1);
try
EditControl.GetTextBuf(Buffer, Size + 1);
P := SearchBuf(Buffer, Size, EditControl.SelStart, EditControl.SelLength,
SearchString, SearchOptions);
if P <> nil then begin
EditControl.SelStart := P - Buffer;
EditControl.SelLength := Length(SearchString);
Result := True;
end;
Finally
StrDispose(Buffer);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
SearchOptions: TStringSearchOptions;
Begin
SearchOptions := [];
if CheckBox1.Checked then
Include(SearchOptions, soDown);
if CheckBox2.Checked then
Include(SearchOptions, soMatchCase);
if CheckBox3.Checked then
Include(SearchOptions, soWholeWord);
SearchEdit(Memo1, Edit1.Text, SearchOptions);
Memo1.SetFocus;
end;
//////////End SearchBuf
━━━━━━━━━━━━━━━━━━━━━
The first function Soundex(const AText: string; ALength: TSoundexLength = 4):
string; $[StrUtils.pas
Function returns the detection string
Explanation: According to the detection method (Soundex), you can find the string of intersecting; http://www.nara.gov/genealogy/coding.html
Reference <NULL>
Example Edit2.Text := Soundex(Edit1.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
Header function SoundexInt(const AText: string; ALength: TSoundexIntLength =
4): Integer; $[StrUtils.pas
Function returns the detecting integer
It means that the greater the value of ALength, the higher the decoding accuracy
Reference <NULL>
Example SpinEdit2.Value := SoundexInt(Edit1.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
Header function DecodeSoundexInt(AValue: Integer): string; $[StrUtils.pas
Function returns the decoding of the probe integer
Description DecodeSoundexInt(SoundexInt('hello')) is equivalent to Soundex('hello')
Reference <NULL>
Example Edit2.Text := DecodeSoundexInt(SpinEdit2.Value);
━━━━━━━━━━━━━━━━━━━━━
First function SoundexWord(const AText: string): Word; $[StrUtils.pas
Function returns the detecting text value
Indicates that there is no parameter ALength that has been fixed to 4
Reference <NULL>
Example SpinEdit2.Value := SoundexWord(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
First function DecodeSoundexWord(AValue: Word): string; $[StrUtils.pas
Function returns the decoding of the detecting text value
Description DecodeSoundexWord(SoundexWord('hello')) is equivalent to Soundex('hello')
Reference <NULL>
Example Edit2.Text := DecodeSoundexWord(SpinEdit2.Value);
━━━━━━━━━━━━━━━━━━━━━
First function SoundexSimilar(const AText, AOther: string; ALength:
TSoundexLength = 4): Boolean; $[StrUtils.pas
Function returns whether the probe strings of the two strings are the same
Description Result := Soundex(AText, ALength) = Soundex(AOther, ALength)
Reference <NULL>
Example CheckBox1.Checked := SoundexSimilar(Edit1.Text, Edit2.Text,
SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
First function SoundexCompare(const AText, AOther: string; ALength:
TSoundexLength = 4): Integer; $[StrUtils.pas
Function returns the result of comparing two strings to detect strings
Description Result := AnsiCompareStr(Soundex(AText, ALength), Soundex(AOther,
ALength))
Reference function SysUtils.AnsiCompareStr
Example SpinEdit2.Value := SoundexCompare(Edit1.Text, Edit2.Text,
SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
First function SoundexProc(const AText, AOther: string): Boolean;
$[StrUtils.pas
Function call SoundexSimilar to return the probe strings of the two strings.
Description of the default value of system variable AnsiResemblesProc
Reference function StrUtils.AnsiResemblesText
Example [var AnsiResemblesProc: TCompareTextProc = SoundexProc;]
━━━━━━━━━━━━━━━━━━━━━
Header function NewStr(const S: string): PString; deprecated; $[SysUtils.pas
Function returns a new string pointer address
Description Return NullStr when string S is empty
Refer to procedure System.New
example
/////////////Begin NewStr,DisposeStr
procedure TForm1.Button1Click(Sender: TObject);
var
P: PString;
Begin
P := NewStr(Edit1.Text);
Edit2.Text := P^;
DisposeStr(P);
end;
/////////////End NewStr,DisposeStr
━━━━━━━━━━━━━━━━━━━━━
First procedure DisposeStr(P: PString); deprecated; $[SysUtils.pas
Function release string pointer P resource
Description Use with NewStr
Refer to procedure System.Dispose
Example <See above, see below>
━━━━━━━━━━━━━━━━━━━━━
First procedure AssignStr(var P: PString; const S: string); deprecated;
$[SysUtils.pas
Function updates string S to string pointer P
Description Resources that were previously string pointers released when updating values
Reference function SysUtils.NewStr;function SysUtils.DisposeStr
example
/////////////Begin AssignStr
procedure TForm1.Button1Click(Sender: TObject);
var
P: PString;
Begin
P := nil;
AssignStr(P, Edit1.Text);
Edit2.Text := P^;
DisposeStr(P);
end;
/////////////End AssignStr
━━━━━━━━━━━━━━━━━━━━━
First procedure AppendStr(var Dest: string; const S: string); deprecated;
$[SysUtils.pas
Function append string S after string Dest
The description is equivalent to Dest := Dest + S; Delphi6 is no longer recommended to use
Reference <NULL>
example
/////////////Begin AppendStr
procedure TForm1.Button1Click(Sender: TObject);
var
S: string;
Begin
S := Edit2.Text;
AppendStr(S, Edit1.Text);
Edit2.Text := S;
end;
////////////End AppendStr
━━━━━━━━━━━━━━━━━━━━━
Header function UpperCase(const S: string): string; $[SysUtils.pas
Function returns the capital form of the string S
Indicates that non-lowercase characters are not processed
Refer to procedure System.SetLength
Example Edit2.Text := UpperCase(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
First function LowerCase(const S: string): string; $[SysUtils.pas
Function returns the lowercase form of the string S
Indicates that non-capsular characters are not processed
Refer to procedure System.SetLength
Example Edit2.Text := LowerCase(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
Header function CompareStr(const S1, S2: string): Integer; $[SysUtils.pas
Function returns to compare two characters
Description When S1>S2 returns value>0; when S1<S2 returns value<0; when S1=S2 returns value=0; case sensitive
Reference <NULL>
Example SpinEdit1.Value := CompareStr(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
First function CompareMem(P1, P2: Pointer; Length: Integer): Boolean;
assembler; $[SysUtils.pas
Function return comparison of two memory pointers
Description CompareMem(PChar('12a'), PChar('12c'), 2)=True;CompareMem(PChar('12a'),
PChar('12c'), 3)=False
Reference <NULL>
Example CheckBox1.Checked := CompareMem(Self, Form1, 8);
━━━━━━━━━━━━━━━━━━━━━
Header function CompareText(const S1, S2: string): Integer; $[SysUtils.pas
Function returns to compare two strings
Indicates case insensitive
Reference <NULL>
Example SpinEdit1.Value := CompareText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
Header function SameText(const S1, S2: string): Boolean; $[SysUtils.pas
Function returns whether two strings are equal
Indicates case insensitive
Reference <NULL>
Example CheckBox1.Checked := SameText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
First function AnsiUpperCase(const S: string): string; $[SysUtils.pas
Function returns the capital form of the string S
Description ANSI (American National Standards Institute) American National Standards Institute; non-lowercase characters remain unchanged
Reference function Windows.CharUpperBuff
Example Edit2.Text := AnsiUpperCase(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
First function AnsiLowerCase(const S: string): string; $[SysUtils.pas
Function returns the lowercase form of the string S
Indicates that non-capsular characters are not processed
Reference function Windows.CharLowerBuff
Example Edit2.Text := AnsiLowerCase(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
Header function AnsiCompareStr(const S1, S2: string): Integer; $[SysUtils.pas
Function reverse comparison of two strings
Description When S1>S2 returns value>0; when S1<S2 returns value<0; when S1=S2 returns value=0; case sensitive
Reference function Windows.CompareString
Example SpinEdit1.Value := AnsiCompareStr(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
Header function AnsiSameStr(const S1, S2: string): Boolean; $[SysUtils.pas
Function returns whether two strings are equal
Description case sensitive
Reference function SysUtils.AnsiCompareStr
Example CheckBox1.Checked := AnsiSameStr(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
Header function AnsiCompareText(const S1, S2: string): Integer; $[SysUtils.pas
Function reverse comparison of two strings
Description When S1>S2 returns value>0; when S1<S2 returns value<0; when S1=S2 returns value=0; case-sensitive
Reference function Windows.CompareString
Example SpinEdit1.Value := AnsiCompareText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
Header function AnsiSameText(const S1, S2: string): Boolean; $[SysUtils.pas
Function returns whether two strings are equal
Indicates case insensitive
Reference function SysUtils.AnsiCompareText
Example CheckBox1.Checked := AnsiSameText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
Header function AnsiStrComp(S1, S2: PChar): Integer; $[SysUtils.pas
Function returns to compare two pointer strings
Description When S1>S2 returns value>0; when S1<S2 returns value<0; when S1=S2 returns value=0; case sensitive
Reference function System.CompareString
Example SpinEdit1.Value := AnsiStrComp(PChar(Edit1.Text), PChar(Edit2.Text))
━━━━━━━━━━━━━━━━━━━━━
Header function AnsiStrIComp(S1, S2: PChar): Integer; $[SysUtils.pas
Function returns to compare two pointer strings
Description When S1>S2 returns value>0; when S1<S2 returns value<0; when S1=S2 returns value=0; case-sensitive; Ignore(ignor)
Reference function Windows.CompareString
Example SpinEdit1.Value := AnsiStrIComp(PChar(Edit1.Text), PChar(Edit2.Text))
━━━━━━━━━━━━━━━━━━━━━
First function AnsiStrLComp(S1, S2: PChar; MaxLen: Cardinal): Integer;
$[SysUtils.pas
Function Return to compare two pointer strings specified length
Description When S1>S2 returns value>0; when S1<S2 returns value<0; when S1=S2 returns value=0; case sensitive; Length (length)
Reference function Windows.CompareString
Example SpinEdit1.Value := AnsiStrLComp(PChar(Edit1.Text), PChar(Edit2.Text),
SpinEdit2.Value)
━━━━━━━━━━━━━━━━━━━━━
First function AnsiStrLIComp(S1, S2: PChar; MaxLen: Cardinal): Integer;
$[SysUtils.pas
Function Return to compare two pointer strings specified length
Description When S1>S2 returns value>0; when S1<S2 returns value<0; when S1=S2 returns value=0; case-sensitive
Reference function Windows.CompareString
Example SpinEdit1.Value := AnsiStrLIComp(PChar(Edit1.Text), PChar(Edit2.Text),
SpinEdit2.Value)
━━━━━━━━━━━━━━━━━━━━━
Header function AnsiStrLower(Str: PChar): PChar; $[SysUtils.pas
Function returns pointer string lowercase
Indicates that non-capsular characters are not processed
Reference function Windows.CharLower
Example Edit2.Text := AnsiStrLower(PChar(Edit1.Text));
━━━━━━━━━━━━━━━━━━━━━
Header function AnsiStrUpper(Str: PChar): PChar; $[SysUtils.pas
Function returns pointer string capitalization
Indicates that non-lowercase characters are not processed
Reference function Windows.CharUpper
Example Edit2.Text := AnsiStrUpper(PChar(Edit1.Text));
━━━━━━━━━━━━━━━━━━━━━
First function AnsiLastChar(const S: string): PChar; $[SysUtils.pas
Function returns the last pointer character of the string S
Description When the string S is an empty string, a null pointer is returned.
Reference function SysUtils.ByteType
Example Edit2.Text := AnsiLastChar(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
Header function AnsiStrLastChar(P: PChar): PChar; $[SysUtils.pas
Function returns the last pointer character of the pointer string P
Description When the string P is an empty pointer, it returns a empty pointer.
Reference function SysUtils.ByteType
Example Edit2.Text := AnsiLastChar(PChar(Edit1.Text));
━━━━━━━━━━━━━━━━━━━━━
Header function WideUpperCase(const S: WideString): WideString; $[SysUtils.pas
Function returns the capitalization of a double-byte string
Description WideChar double-byte characters
Reference function Windows.CharUpperBuffW
Example Edit2.Text := WideUpperCase(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
First function WideLowerCase(const S: WideString): WideString; $[SysUtils.pas
Function returns the lowercase form of a double-byte string
It means why I can't test it
Reference function Windows.CharLowerBuffW
Example Edit2.Text := WideLowerCase(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
First function WideCompareStr(const S1, S2: WideString): Integer;
$[SysUtils.pas
Function Return Comparison of Two Double Byte Strings
Description When S1>S2 returns value>0; when S1<S2 returns value<0; when S1=S2 returns value=0; case sensitive
Reference function Windows.CompareStringW
Example SpinEdit1.Value := WideCompareStr(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
First function WideSameStr(const S1, S2: WideString): Boolean; $[SysUtils.pas
Function returns whether two double-byte strings are the same
Description case sensitive
Reference function SysUtils.WideCompareStr
Example CheckBox1.Checked := WideSameStr(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
First function WideCompareText(const S1, S2: WideString): Integer;
$[SysUtils.pas
Function Return Comparison of Two Double Byte Strings
Description When S1>S2 returns value>0; when S1<S2 returns value<0; when S1=S2 returns value=0; case-sensitive
Reference function Windows.CompareStringW
Example SpinEdit1.Value := WideCompareText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
First function WideSameText(const S1, S2: WideString): Boolean;
$[SysUtils.pas
Function returns whether two double-byte strings are the same
Indicates case insensitive
Reference function SysUtils.WideCompareText
Example CheckBox1.Checked := WideSameText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
Header function Trim(const S: string): string; overload; $[SysUtils.pas
First function Trim(const S: WideString): WideString; overload;
$[SysUtils.pas
Function returns to remove the left and right characters of the string S
Characters that indicate that less than #32 are considered invisible characters
Refer to function System.Copy
Example Edit2.Text := Trim(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
Header function TrimLeft(const S: string): string; overload; $[SysUtils.pas
First function TrimLeft(const S: WideString): WideString; overload;
$[SysUtils.pas
Function return to remove the invisible characters on the left of the string S
Characters that indicate that less than #32 are considered invisible characters
Refer to function System.Copy
Example Edit2.Text := TrimLeft(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
Header function TrimRight(const S: string): string; overload; $[SysUtils.pas
First function TrimRight(const S: WideString): WideString; overload;
$[SysUtils.pas
Function return to remove the invisible characters on the right of the string S
Characters that indicate that less than #32 are considered invisible characters
Refer to function System.Copy
Example Edit2.Text := TrimRight(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
Header function QuotedStr(const S: string): string; $[SysUtils.pas
Function returns the expression of the string S in pascal
Explanation: One single quote in single quote will be converted into two
Refer to procedure System.Insert
Example Edit2.Text := QuotedStr(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
First function AnsiQuotedStr(const S: string; Quote: Char): string;
$[SysUtils.pas
Function returns the expression of the string S with the character Quote as quotes
Description AnsiQuotedStr('hello"world',
'@')='@hello"world@';AnsiQuotedStr('hello"world', '"')='"hello""world"'
Reference function SysUtils.AnsiStrScan
Example Edit2.Text := AnsiQuotedStr(Edit1.Text, '"');
━━━━━━━━━━━━━━━━━━━━━
First function AnsiExtractQuotedStr(var Src: PChar; Quote: Char): string;
$[SysUtils.pas
Function returns the original form of the character Quote as quotes
It means that Src remains unchanged when the expression is illegal. Otherwise, it will be empty.
Reference function SysUtils.AnsiStrScan
example
//////////Begin AnsiExtractQuotedStr
procedure TForm1.Button1Click(Sender: TObject);
var
P: PChar;
Begin
P := PChar(Edit1.Text);
Edit2.Text := AnsiExtractQuotedStr(P, '"');
Edit3.Text := P;
end;
//////////End AnsiExtractQuotedStr
━━━━━━━━━━━━━━━━━━━━━
First function AnsiDequotedStr(const S: string; AQuote: Char): string;
$[SysUtils.pas
Function returns the original form of the character AQuote as quotes
When the expression is illegal, it returns S
Reference function SysUtils.AnsiExtractQuotedStr
Example Edit2.Text := AnsiDequotedStr(Edit1.Text, '"');
━━━━━━━━━━━━━━━━━━━━━
First function AdjustLineBreaks(const S: string; Style: TTextLineBreakStyle =
{$IFDEF linux} tlbsLF {$ENDIF} {$IFDEF MSWINDOWS} tlbsCRLF {$ENDIF}):
string; $[SysUtils.pas
Function returns to adjust the line separator of the given string to a CR/LF sequence
illustrate
AdjustLineBreaks('1'#13'2'#13)='1'#13#10'2'#13#10;AdjustLineBreaks('1'#10'2'#10)='1'#13#10 '2'#13#10
Reference function SysUtils.StrNextChar
Example <NULL>
━━━━━━━━━━━━━━━━━━━━━
Header function IsValidIdent(const Ident: string): Boolean; $[SysUtils.pas
Function returns whether the string Ident is the correct identifier
Description Identifier::Letters|Underlines[Letters|Underlines|Numbers]...
Reference <NULL>
Example CheckBox1.Checked := IsValidIdent(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
Header function IntToStr(Value: Integer): string; overload; $[SysUtils.pas
Header function IntToStr(Value: Int64): string; overload; $[SysUtils.pas
Function returns integer value to convert to string
Description Format('%d', [Value])
Reference function SysUtils.FmtStr
Example Edit2.Text := IntToStr(SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
First function IntToHex(Value: Integer; Digits: Integer): string; overload;
$[SysUtils.pas
First function IntToHex(Value: Int64; Digits: Integer): string; overload;
$[SysUtils.pas
Function returns integer value converted to hexadecimal performance result; Format('%.*x', [Digits, Value])
Description Parameter Digits specifies the minimum width of the character; if the minimum width is insufficient, it will be filled with 0.
Reference function SysUtils.FmtStr
Example Edit2.Text := IntToHex(SpinEdit1.Value, SpinEdit2.Value);
━━━━━━━━━━━━━━━━━━━━━
Header function StrToInt(const S: string): Integer; $[SysUtils.pas
Function returns the string S to convert it into an integer
Explanation: An exception will be caused when a string is expressed by non-integral
Refer to procedure System.Val
Example SpinEdit1.Value := StrToInt(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
First function StrToIntDef(const S: string; Default: Integer): Integer;
$[SysUtils.pas
Function returns the string S to convert it into an integer
Default is returned when the string is expressed by non-integral.
Refer to procedure System.Val
Example SpinEdit1.Value := StrToIntDef(Edit1.Text, 0);
━━━━━━━━━━━━━━━━━━━━━
First function TryStrToInt(const S: string; out Value: Integer): Boolean;
$[SysUtils.pas
Function returns whether the string S is converted to integer Value successfully
Description False is returned when the string is expressed by non-integer and Value will output as 0
Refer to procedure System.Val
example
//////////Begin TryStrToInt
procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
Begin
CheckBox1.Checked := TryStrToInt(Edit1.Text, I);
SpinEdit1.Value := I;
end;
//////////End TryStrToInt
━━━━━━━━━━━━━━━━━━━━━
Header function StrToInt64(const S: string): Int64; $[SysUtils.pas
Function returns the string S to convert it into a sixty-four-bit integer
Explanation: An exception will be caused when a string is expressed by a non-64-bit integer.
Refer to procedure System.Val
Example SpinEdit1.Value := StrToInt64(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
First function StrToInt64Def(const S: string; const Default: Int64): Int64;
$[SysUtils.pas
Function returns the string S to convert it into a sixty-four-bit integer
Default is returned when the string is expressed by non-64-bit integer.
Refer to procedure System.Val
Example SpinEdit1.Value := StrToInt64Def(Edit1.Text, 0);
━━━━━━━━━━━━━━━━━━━━━
First function TryStrToInt64(const S: string; out Value: Int64): Boolean;
$[SysUtils.pas
Function Returns whether the string S is converted into a sixty-four-bit integer value successfully
Description False is returned when the string is expressed by non-sixty-four-bit integer and Value will output as 0
Refer to procedure System.Val
example
//////////Begin TryStrToInt64
procedure TForm1.Button1Click(Sender: TObject);
var
I: Int64;
Begin
CheckBox1.Checked := TryStrToInt64(Edit1.Text, I);
SpinEdit1.Value := I;
end;
//////////End TryStrToInt64
━━━━━━━━━━━━━━━━━━━━━
First function StrToBool(const S: string): Boolean; $[SysUtils.pas
Function returns the string S to convert it into logical value
Explanation character will cause exceptions when it is not logically expressed
Reference function SysUtils.TryStrToBool
Example CheckBox1.Checked := StrToBool(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
The first function StrToBoolDef(const S: string; const Default: Boolean):
Boolean; $[SysUtils.pas
Function returns the string S to convert it into logical value
When describing characters are not logically expressed, the default value is returned.
Reference function SysUtils.TryStrToBool
Example CheckBox1.Checked := StrToBoolDef(Edit1.Text, False);
━━━━━━━━━━━━━━━━━━━━━
First function TryStrToBool(const S: string; out Value: Boolean): Boolean;
$[SysUtils.pas
Function return string S to convert it into logical value. Whether it is successful?
Note [Note] 0 is false, not 0 is true; it is not 'True' and 'False'; Delphi6 bug is corrected as follows
Reference function SysUtils.AnsiSameText;var SysUtils.TrueBoolStrs;var
SysUtils.FalseBoolStrs
example
//////////Begin TryStrToBool
procedure TForm1.Button1Click(Sender: TObject);
var
B: Boolean;
Begin
SetLength(TrueBoolStrs, 2);
SetLength(FalseBoolStrs, 2);
TrueBoolStrs[0] := 'True';
FalseBoolStrs[0] := 'False';
TrueBoolStrs[1] := 'Yes';
FalseBoolStrs[1] := 'No';
CheckBox1.Checked := TryStrToBool(Edit1.Text, B);
CheckBox2.Checked := B;
end;
//////////End TryStrToBool
Attached
//////////Begin TryStrToBool
function TryStrToBool(const S: string; out Value: Boolean): Boolean;
function CompareWith(const aArray: array of string): Boolean;
var
I: Integer;
Begin
Result := False;
for I := Low(aArray) to High(aArray) do
if AnsiSameText(S, aArray[I]) then
Begin
Result := True;
Break;
end;
end;
var
LResult: Extended;
Begin
Result := TryStrToFloat(S, LResult);
If Results then
Value := LResult <> 0
else
Begin
Result := True; //Revision
VerifyBoolStrArray;
if CompareWith(TrueBoolStrs) then
Value := True
else if CompareWith(FalseBoolStrs) then
Value := False
else
Result := False;
end;
end;
//////////End TryStrToBool
━━━━━━━━━━━━━━━━━━━━━
First function BoolToStr(B: Boolean; UseBoolStrs: Boolean = False): string;
$[SysUtils.pas
Function returns the logical value B to convert it into a string
Description BoolToStr(False, False)='0'; BoolToStr(False, True)='-1'
Reference var SysUtils.TrueBoolStrs; var SysUtils.FalseBoolStrs
Example Edit1.Text := BoolToStr(CheckBox1.Checked, CheckBox2.Checked);
━━━━━━━━━━━━━━━━━━━━━
Header function LoadStr(Ident: Integer): string; $[SysUtils.pas
Function returns string resources based on the Identification Ident
Explanation string resources refer to the internal resources of the program
Reference function SysUtils.FindStringResource
Example Edit2.Text := LoadStr(StrToIntDef(Edit1.Text, 0));
━━━━━━━━━━━━━━━━━━━━━
First function FmtLoadStr(Ident: Integer; const Args: array of const):
string; $[SysUtils.pas
Function returns formatted string resources
Explanation string resources refer to the internal resources of the program
Reference function SysUtils.FmtStr;function SysUtils.FindStringResource
Example <NULL>;
━━━━━━━━━━━━━━━━━━━━━
Header function StrLen(const Str: PChar): Cardinal; $[SysUtils.pas
Function returns the length of the pointer string
Explanation: When the pointer string Str is nil, an exception will be triggered.
Reference <NULL>
Example SpinEdit2.Value := StrLen(PChar(Edit1.Text));
━━━━━━━━━━━━━━━━━━━━━
首部function StrEnd(const Str: PChar): PChar; $[SysUtils.pas
功能返回指针字符串的结尾
说明当指针字符串Str为nil时将触发异常
参考<NULL>
例子Edit2.Text := StrEnd(PChar(Edit1.Text)) - SpinEdit1.Value;
━━━━━━━━━━━━━━━━━━━━━
首部function StrMove(Dest: PChar; const Source: PChar; Count: Cardinal):
PChar; $[SysUtils.pas
功能返回将指针字符串Source指定内存数量Count复制覆盖到指针字符串Dest中
说明Dest没有分配资源将触发异常s
参考function System.Move
example
///////Begin StrMove
procedure TForm1.Button1Click(Sender: TObject);
var
vBuffer: PChar;
Begin
vBuffer := '0123456789';
StrMove(vBuffer, PChar(Edit1.Text), SpinEdit1.Value);
Edit2.Text := vBuffer;
end;
///////End StrMove
━━━━━━━━━━━━━━━━━━━━━
首部function StrCopy(Dest: PChar; const Source: PChar): PChar;
$[SysUtils.pas
功能返回将指针字符串Source复制到指针字符串Dest中
说明Dest应已经分配足够的空间非则将触发异常
参考<NULL>
example
///////Begin StrCopy
procedure TForm1.Button1Click(Sender: TObject);
var
vBuffer: PChar;
Begin
GetMem(vBuffer, Length(Edit1.Text) + 1);
StrCopy(vBuffer, PChar(Edit1.Text));
Edit2.Text := vBuffer;
FreeMem(vBuffer);
end;
///////End StrCopy
━━━━━━━━━━━━━━━━━━━━━
首部function StrECopy(Dest:PChar; const Source: PChar): PChar;
$[SysUtils.pas
功能返回将指针字符串Source复制到指针字符串Dest中的结尾
说明可以连接指针字符串
参考<NULL>
example
///////Begin StrECopy
procedure TForm1.Button1Click(Sender: TObject);
var
vBuffer: array[0..255] of Char;
Begin
StrECopy(StrECopy(vBuffer, PChar(Edit1.Text)), PChar(Edit2.Text));
Edit3.Text := vBuffer;
end;
///////End StrECopy
━━━━━━━━━━━━━━━━━━━━━
首部function StrLCopy(Dest: PChar; const Source: PChar; MaxLen: Cardinal):
PChar; $[SysUtils.pas
功能返回将指针字符串Source指定长度MaxLen复制到指针字符串Dest中
说明Dest应已经分配足够的空间非则将触发异常
参考<NULL>
example
///////Begin StrLCopy
procedure TForm1.Button1Click(Sender: TObject);
var
vBuffer: array[0..255] of Char;
Begin
StrLCopy(vBuffer, PChar(Edit1.Text), SpinEdit1.Value);
Edit2.Text := vBuffer;
end;
///////End StrLCopy
━━━━━━━━━━━━━━━━━━━━━
首部function StrPCopy(Dest: PChar; const Source: string): PChar;
$[SysUtils.pas
功能返回将指针字符串Source复制到指针字符串Dest中
说明StrLCopy(Dest, PChar(Source), Length(Source))
参考function SysUtils.StrLCopy
example
///////Begin StrPCopy
procedure TForm1.Button1Click(Sender: TObject);
var
vBuffer: array[0..255] of Char;
Begin
StrPCopy(vBuffer, PChar(Edit1.Text));
Edit2.Text := vBuffer;
end;
///////End StrPCopy
━━━━━━━━━━━━━━━━━━━━━
首部function StrPLCopy(Dest: PChar; const Source: string; MaxLen:
Cardinal): PChar; $[SysUtils.pas
功能返回将字符串Source指定长度MaxLen复制到指针字符串Dest中
说明StrLCopy(Dest, PChar(Source), MaxLen)
参考function SysUtils.StrLCopy
example
///////Begin StrPLCopy
procedure TForm1.Button1Click(Sender: TObject);
var
vBuffer: array[0..255] of Char;
Begin
StrPLCopy(vBuffer, Edit1.Text, SpinEdit1.Value);
Edit2.Text := vBuffer;
end;
///////End StrPLCopy
━━━━━━━━━━━━━━━━━━━━━
首部function StrCat(Dest: PChar; const Source: PChar): PChar;
$[SysUtils.pas
功能返回连接指针字符串Dest和指针字符串Source
说明StrCopy(StrEnd(Dest), Source)
参考function SysUntils.StrCopy
example
///////Begin StrCat
procedure TForm1.Button1Click(Sender: TObject);
var
vBuffer: array[0..255] of Char;
Begin
StrPCopy(vBuffer, Edit1.Text);
StrCat(vBuffer, PChar(Edit2.Text));
Edit3.Text := vBuffer;
end;
///////End StrCat
━━━━━━━━━━━━━━━━━━━━━
首部function StrLCat(Dest: PChar; const Source: PChar; MaxLen: Cardinal):
PChar; $[SysUtils.pas
功能返回连接指针字符串Dest和指针字符串Source
说明[注意]MaxLen指定连接后的最大长度不是指针字符串Source的长度
参考<NULL>
example
///////Begin StrLCat
procedure TForm1.Button1Click(Sender: TObject);
var
vBuffer: array[0..255] of Char;
Begin
StrPCopy(vBuffer, Edit1.Text);
StrLCat(vBuffer, PChar(Edit2.Text), SpinEdit1.Value);
Edit3.Text := vBuffer;
end;
///////End StrLCat
━━━━━━━━━━━━━━━━━━━━━
首部function StrComp(const Str1, Str2: PChar): Integer; $[SysUtils.pas
功能返回比较两个指针字符串
说明当S1>S2返回值>0;当S1<S2返回值<0;当S1=S2返回值=0;区分大小写;[注意]返回第一个出现不同字符的差异
参考<NULL>
例子SpinEdit1.Value := StrComp(PChar(Edit1.Text), PChar(Edit2.Text));
━━━━━━━━━━━━━━━━━━━━━
首部function StrIComp(const Str1, Str2: PChar): Integer; $[SysUtils.pas
功能返回比较两个指针字符串
说明当S1>S2返回值>0;当S1<S2返回值<0;当S1=S2返回值=0;不区分大小写;[注意]返回第一个出现不同字符的差异
参考<NULL>
例子SpinEdit1.Value := StrIComp(PChar(Edit1.Text), PChar(Edit2.Text));
━━━━━━━━━━━━━━━━━━━━━
首部function StrLComp(const Str1, Str2: PChar; MaxLen: Cardinal): Integer;
$[SysUtils.pas
功能返回比较两个指针字符串指定长度
说明当S1>S2返回值>0;当S1<S2返回值<0;当S1=S2返回值=0;区分大小写;Length(长度);[注意]返回第一个出现不同字符的差异
参考<NULL>
例子SpinEdit1.Value := StrLComp(PChar(Edit1.Text), PChar(Edit2.Text),
SpinEdit2.Value)
━━━━━━━━━━━━━━━━━━━━━
首部function StrLIComp(const Str1, Str2: PChar; MaxLen: Cardinal): Integer;
$[SysUtils.pas
功能返回比较两个指针字符串指定长度
说明当S1>S2返回值>0;当S1<S2返回值<0;当S1=S2返回值=0;不区分大小写;[注意]返回第一个出现不同字符的差异
参考<NULL>
例子SpinEdit1.Value := StrLIComp(PChar(Edit1.Text), PChar(Edit2.Text),
SpinEdit2.Value)
━━━━━━━━━━━━━━━━━━━━━
首部function StrScan(const Str: PChar; Chr: Char): PChar; $[SysUtils.pas
功能返回在指针字符串Str搜索字符Chr第一个出现的地址
说明没有找到则返回空指针
参考<NULL>
例子Edit2.Text := StrScan(PChar(Edit1.Text), '*');
━━━━━━━━━━━━━━━━━━━━━
首部function StrRScan(const Str: PChar; Chr: Char): PChar; $[SysUtils.pas
功能返回在指针字符串Str搜索字符Chr最后一个出现的地址
说明没有找到则返回空指针
参考<NULL>
例子Edit2.Text := StrRScan(PChar(Edit1.Text), '*');
━━━━━━━━━━━━━━━━━━━━━
首部function StrPos(const Str1, Str2: PChar): PChar; $[SysUtils.pas
功能返回指针字符串Str2在Str1中第一个出现的地址
说明没有找到则返回空指针;StrPos('12345', '3') = '345'
参考<NULL>
例子Edit3.Text := StrPos(PChar(Edit1.Text), PChar(