這些DELPHI函數是我在參加認證培訓的時候在老師那裏弄來的,很不錯!
首部 function AnsiResemblesText(const AText, AOther: string): Boolean; $[StrUtils.pas
功能 返回兩個字符串是否相似
說明 ANSI(American National Standards Institute)美國國家標准協會;不區分大小寫
參考 function StrUtils.SoundexProc; var StrUtils.AnsiResemblesProc
例子 CheckBox1.Checked := AnsiResemblesText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiContainsText(const AText, ASubText: string): Boolean; $[StrUtils.pas
功能 返回字符串AText是否包含子串ASubText
說明 不區分大小寫
參考 function StrUtils.AnsiUppercase; function StrUtils.AnsiPos
例子 CheckBox1.Checked := AnsiContainsText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiStartsText(const ASubText, AText: string): Boolean; $[StrUtils.pas
功能 返回字符串AText是否以子串ASubText開頭
說明 不區分大小寫
參考 function Windows.CompareString
例子 CheckBox1.Checked := AnsiStartsText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiEndsText(const ASubText, AText: string): Boolean; $[StrUtils.pas
功能 返回字符串AText是否以子串ASubText結尾
說明 不區分大小寫
參考 function Windows.CompareString
例子 CheckBox1.Checked := AnsiEndsText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiReplaceText(const AText, AFromText, AToText: string): string; $[StrUtils.pas
功能 返回字符串AText中用子串AFromText替換成子串AToText的結果
說明 不區分大小寫
參考 function SysUtils.StringReplace; type SysUtils.TReplaceFlags
例子 Edit4.Text := AnsiReplaceText(Edit1.Text, Edit2.Text, Edit3.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiMatchText(const AText: string; const AValues: array of string): Boolean; $[StrUtils.pas
功能 返回字符串數組AValues中是否包含字符串AText
說明 不區分大小寫
參考 function StrUtils.AnsiIndexText
例子 CheckBox1.Checked := AnsiMatchText(Edit1.Text, ['a1', 'a2', 'a3', 'a4']);
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiIndexText(const AText: string; const AValues: array of string): Integer; $[StrUtils.pas
功能 返回字符串AText在字符串數組AValues中的位置
說明 不區分大小寫;如果不包含則返回-1
參考 function SysUtils.AnsiSameText
例子 SpinEdit1.Value := AnsiIndexText(Edit1.Text, ['a1', 'a2', 'a3', 'a4']);
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiContainsStr(const AText, ASubText: string): Boolean; $[StrUtils.pas
功能 返回字符串AText是否包含子串ASubText
說明 區分大小寫
參考 function StrUtils.AnsiPos
例子 CheckBox1.Checked := AnsiContainsStr(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiStartsStr(const ASubText, AText: string): Boolean; $[StrUtils.pas
功能 返回字符串AText是否以子串ASubText開頭
說明 區分大小寫
參考 function SysUtils.AnsiSameStr
例子 CheckBox1.Checked := AnsiStartsStr(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiEndsStr(const ASubText, AText: string): Boolean; $[StrUtils.pas
功能 返回字符串AText是否以子串ASubText結尾
說明 區分大小寫
參考 function SysUtils.AnsiSameStr
例子 CheckBox1.Checked := AnsiEndsStr(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiReplaceStr(const AText, AFromText, AToText: string): string; $[StrUtils.pas
功能 返回字符串AText中用子串AFromText替換成子串AToText的結果
說明 區分大小寫
參考 function SysUtils.StringReplace; type SysUtils.TReplaceFlags
例子 Edit4.Text := AnsiReplaceStr(Edit1.Text, Edit2.Text, Edit3.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiMatchStr(const AText: string; const AValues: array of string): Boolean; $[StrUtils.pas
功能 返回字符串數組AValues中是否包含字符串AText
說明 區分大小寫
參考 function StrUtils.AnsiIndexStr
例子 CheckBox1.Checked := AnsiMatchStr(Edit1.Text, ['a1', 'a2', 'a3', 'a4']);
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiIndexStr(const AText: string; const AValues: array of string): Integer; $[StrUtils.pas
功能 返回字符串AText在字符串數組AValues中的位置
說明 區分大小寫
參考 function SysUtils.AnsiSameStr
例子 SpinEdit1.Value := AnsiIndexStr(Edit1.Text, ['a1', 'a2', 'a3', 'a4']);
━━━━━━━━━━━━━━━━━━━━━
首部 function DupeString(const AText: string; ACount: Integer): string; $[StrUtils.pas
功能 返回字符串AText的ACount個複本
說明 當ACount爲0時返回''
參考 function System.SetLength
例子 Edit3.Text := DupeString(Edit1.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
首部 function ReverseString(const AText: string): string; $[StrUtils.pas
功能 返回字符串AText的反序
說明 ReverseString('1234') = '4321'
參考 function System.SetLength
例子 Edit3.Text := ReverseString(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function StuffString(const AText: string; AStart, ALength: Cardinal; const ASubText: string): string; $[StrUtils.pas
功能 返回嵌套字符串
說明 AStart:嵌套開始位置;ALength:嵌套長度;StuffString('abcd', 2, 0, '12') = 'a12bcd'
參考 function System.Copy
例子 Edit3.Text := StuffString(Edit1.Text, SpinEdit1.Value, SpinEdit2.Value, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function RandomFrom(const AValues: array of string): string; overload; $[StrUtils.pas
功能 隨機返回字符串數組AValues中的一個元素
說明 之前建議執行Randomize
參考 function System.Random
例子 Randomize; Edit3.Text := RandomFrom(['a1', 'a2', 'a3', 'a4']);
━━━━━━━━━━━━━━━━━━━━━
首部 function IfThen(AValue: Boolean; const ATrue: string; AFalse: string = ''): string; overload; $[StrUtils.pas
功能 返回指定的邏輯字符串
說明 IfThen(True, '是', '否') = '是';IfThen(False, '是', '否') = '否'
參考 <NULL>
例子 Edit3.Text := IfThen(CheckBox1.Checked, Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function LeftStr(const AText: string; const ACount: Integer): string; $[StrUtils.pas
功能 返回字符串AText左邊的ACount個字符
說明 LeftStr('123456', 3) = '123'
參考 function System.Copy
例子 Edit3.Text := LeftStr(Edit1.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
首部 function RightStr(const AText: string; const ACount: Integer): string; $[StrUtils.pas
功能 返回字符串AText右邊的ACount個字符
說明 RightStr('123456', 3) = '456'
參考 function System.Copy
例子 Edit3.Text := RightStr(Edit1.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
首部 function MidStr(const AText: string; const AStart, ACount: Integer): string; $[StrUtils.pas
功能 返回字符串AText從AStart開始的ACount個字符
說明 其實就是Copy
參考 function System.Copy
例子 Edit3.Text := MidStr(Edit1.Text, SpinEdit1.Value, SpinEdit2.Value);
━━━━━━━━━━━━━━━━━━━━━
首部 function SearchBuf(Buf: PChar; BufLen: Integer; SelStart, SelLength: Integer; SearchString: String; Options: TStringSearchOptions = [soDown]): PChar; $[StrUtils.pas
功能 返回第一個搜索到的指針位置
說明 這函數常用于文本中搜索字符串
參考 <NULL>
例子
///////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
━━━━━━━━━━━━━━━━━━━━━
首部 function Soundex(const AText: string; ALength: TSoundexLength = 4): string; $[StrUtils.pas
功能 返回探測字符串
說明 根據探測法(Soundex)可以找到相進的字符串;http://www.nara.gov/genealogy/coding.html
參考 <NULL>
例子 Edit2.Text := Soundex(Edit1.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
首部 function SoundexInt(const AText: string; ALength: TSoundexIntLength = 4): Integer; $[StrUtils.pas
功能 返回探測整數
說明 ALength的值越大解碼准確率越高
參考 <NULL>
例子 SpinEdit2.Value := SoundexInt(Edit1.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
首部 function DecodeSoundexInt(AValue: Integer): string; $[StrUtils.pas
功能 返回探測整數的解碼
說明 DecodeSoundexInt(SoundexInt('hello')) 相當于 Soundex('hello')
參考 <NULL>
例子 Edit2.Text := DecodeSoundexInt(SpinEdit2.Value);
━━━━━━━━━━━━━━━━━━━━━
首部 function SoundexWord(const AText: string): Word; $[StrUtils.pas
功能 返回探測文字數值
說明 沒有參數ALength已經固定爲4
參考 <NULL>
例子 SpinEdit2.Value := SoundexWord(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function DecodeSoundexWord(AValue: Word): string; $[StrUtils.pas
功能 返回探測文字數值的解碼
說明 DecodeSoundexWord(SoundexWord('hello')) 相當于 Soundex('hello')
參考 <NULL>
例子 Edit2.Text := DecodeSoundexWord(SpinEdit2.Value);
━━━━━━━━━━━━━━━━━━━━━
首部 function SoundexSimilar(const AText, AOther: string; ALength: TSoundexLength = 4): Boolean; $[StrUtils.pas
功能 返回兩個字符串的探測字符串是否相同
說明 Result := Soundex(AText, ALength) = Soundex(AOther, ALength)
參考 <NULL>
例子 CheckBox1.Checked := SoundexSimilar(Edit1.Text, Edit2.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
首部 function SoundexCompare(const AText, AOther: string; ALength: TSoundexLength = 4): Integer; $[StrUtils.pas
功能 返回比較兩個字符串的探測字符串的結果
說明 Result := AnsiCompareStr(Soundex(AText, ALength), Soundex(AOther, ALength))
參考 function SysUtils.AnsiCompareStr
例子 SpinEdit2.Value := SoundexCompare(Edit1.Text, Edit2.Text, SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
首部 function SoundexProc(const AText, AOther: string): Boolean; $[StrUtils.pas
功能 調用SoundexSimilar返回兩個字符串的探測字符串是否相同
說明 系統變量AnsiResemblesProc的默認值
參考 function StrUtils.AnsiResemblesText
例子 [var AnsiResemblesProc: TCompareTextProc = SoundexProc;]
首部 function Languages: TLanguages; $[SysUtils.pas
功能 返回系統語言對象
說明 通過此函數可以得到系統的語言環境
參考 type SysUtils.TLanguages
例子
///////Begin Languages
procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
begin
Memo1.Clear;
for I := 0 to Languages.Count - 1 do
Memo1.Lines.Add(Languages.Name[I]);
end;
///////End Languages
━━━━━━━━━━━━━━━━━━━━━
首部 function AllocMem(Size: Cardinal): Pointer; $[SysUtils.pas
功能 返回一個指定大小Size的內存塊
說明 配合用FreeMem釋放資源
參考 function System.GetMem
例子
///////Begin AllocMem
procedure TForm1.Button1Click(Sender: TObject);
var
I: PInteger;
begin
I := AllocMem(SizeOf(Integer));
I^ := 100;
Edit1.Text := IntToStr(I^);
FreeMem(I, SizeOf(Integer));
end;
///////End AllocMem
━━━━━━━━━━━━━━━━━━━━━
首部 procedure AddExitProc(Proc: TProcedure); $[SysUtils.pas
功能 添加一個退出處理的過程
說明 建議用finalization部分取代
參考 <NULL>
例子
////////Begin AddExitProc
uses
ShellApi;
procedure ExitProc;
begin
ShellExecute(0, 'Open', 'Calc.exe', nil, nil, SW_SHOW);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
AddExitProc(ExitProc);
end;
////////End AddExitProc
━━━━━━━━━━━━━━━━━━━━━
首部 function NewStr(const S: string): PString; deprecated; $[SysUtils.pas
功能 返回一個新的字符串指針地址
說明 字符串S爲空時返回NullStr
參考 procedure System.New
例子
////////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
━━━━━━━━━━━━━━━━━━━━━
首部 procedure DisposeStr(P: PString); deprecated; $[SysUtils.pas
功能 釋放字符串指針P資源
說明 配合函數NewStr使用
參考 procedure System.Dispose
例子 <如上參見,如下參見>
━━━━━━━━━━━━━━━━━━━━━
首部 procedure AssignStr(var P: PString; const S: string); deprecated; $[SysUtils.pas
功能 將字符串S更新給字符串指針P
說明 更新值時會釋放以前字符串指針的資源
參考 function SysUtils.NewStr;function SysUtils.DisposeStr
例子
////////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
━━━━━━━━━━━━━━━━━━━━━
首部 procedure AppendStr(var Dest: string; const S: string); deprecated; $[SysUtils.pas
功能 在字符串Dest後追加字符串S
說明 相當于Dest := Dest + S;Delphi6已經不建議使用
參考 <NULL>
例子
////////Begin AppendStr
procedure TForm1.Button1Click(Sender: TObject);
var
S: string;
begin
S := Edit2.Text;
AppendStr(S, Edit1.Text);
Edit2.Text := S;
end;
////////End AppendStr
━━━━━━━━━━━━━━━━━━━━━
首部 function UpperCase(const S: string): string; $[SysUtils.pas
功能 返回字符串S的大寫形式
說明 非小寫字符不處理
參考 procedure System.SetLength
例子 Edit2.Text := UpperCase(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function LowerCase(const S: string): string; $[SysUtils.pas
功能 返回字符串S的小寫形式
說明 非大寫字符不處理
參考 procedure System.SetLength
例子 Edit2.Text := LowerCase(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function CompareStr(const S1, S2: string): Integer; $[SysUtils.pas
功能 返回比較兩個字符
說明 當S1>S2返回值>0;當S1<S2返回值<0;當S1=S2返回值=0;區分大小寫
參考 <NULL>
例子 SpinEdit1.Value := CompareStr(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function CompareMem(P1, P2: Pointer; Length: Integer): Boolean; assembler; $[SysUtils.pas
功能 返回比較兩個內存指針
說明 CompareMem(PChar('12a'), PChar('12c'), 2)=True;CompareMem(PChar('12a'), PChar('12c'), 3)=False
參考 <NULL>
例子 CheckBox1.Checked := CompareMem(Self, Form1, 8);
━━━━━━━━━━━━━━━━━━━━━
首部 function CompareText(const S1, S2: string): Integer; $[SysUtils.pas
功能 返回比較兩個字符串
說明 不區分大小寫
參考 <NULL>
例子 SpinEdit1.Value := CompareText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function SameText(const S1, S2: string): Boolean; $[SysUtils.pas
功能 返回兩個字符串是否相等
說明 不區分大小寫
參考 <NULL>
例子 CheckBox1.Checked := SameText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiUpperCase(const S: string): string; $[SysUtils.pas
功能 返回字符串S的大寫形式
說明 ANSI(American National Standards Institute)美國國家標准協會;非小寫的字符不變
參考 function Windows.CharUpperBuff
例子 Edit2.Text := AnsiUpperCase(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiLowerCase(const S: string): string; $[SysUtils.pas
功能 返回字符串S的小寫形式
說明 非大寫字符不處理
參考 function Windows.CharLowerBuff
例子 Edit2.Text := AnsiLowerCase(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiCompareStr(const S1, S2: string): Integer; $[SysUtils.pas
功能 反回比較兩個字符串
說明 當S1>S2返回值>0;當S1<S2返回值<0;當S1=S2返回值=0;區分大小寫
參考 function Windows.CompareString
例子 SpinEdit1.Value := AnsiCompareStr(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiSameStr(const S1, S2: string): Boolean; $[SysUtils.pas
功能 返回兩個字符串是否相等
說明 區分大小寫
參考 function SysUtils.AnsiCompareStr
例子 CheckBox1.Checked := AnsiSameStr(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiCompareText(const S1, S2: string): Integer; $[SysUtils.pas
功能 反回比較兩個字符串
說明 當S1>S2返回值>0;當S1<S2返回值<0;當S1=S2返回值=0;不區分大小寫
參考 function Windows.CompareString
例子 SpinEdit1.Value := AnsiCompareText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiSameText(const S1, S2: string): Boolean; $[SysUtils.pas
功能 返回兩個字符串是否相等
說明 不區分大小寫
參考 function SysUtils.AnsiCompareText
例子 CheckBox1.Checked := AnsiSameText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiStrComp(S1, S2: PChar): Integer; $[SysUtils.pas
功能 返回比較兩個指針字符串
說明 當S1>S2返回值>0;當S1<S2返回值<0;當S1=S2返回值=0;區分大小寫
參考 function System.CompareString
例子 SpinEdit1.Value := AnsiStrComp(PChar(Edit1.Text), PChar(Edit2.Text))
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiStrIComp(S1, S2: PChar): Integer; $[SysUtils.pas
功能 返回比較兩個指針字符串
說明 當S1>S2返回值>0;當S1<S2返回值<0;當S1=S2返回值=0;不區分大小寫;Ignore(忽略)
參考 function Windows.CompareString
例子 SpinEdit1.Value := AnsiStrIComp(PChar(Edit1.Text), PChar(Edit2.Text))
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiStrLComp(S1, S2: PChar; MaxLen: Cardinal): Integer; $[SysUtils.pas
功能 返回比較兩個指針字符串指定長度
說明 當S1>S2返回值>0;當S1<S2返回值<0;當S1=S2返回值=0;區分大小寫;Length(長度)
參考 function Windows.CompareString
例子 SpinEdit1.Value := AnsiStrLComp(PChar(Edit1.Text), PChar(Edit2.Text), SpinEdit2.Value)
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiStrLIComp(S1, S2: PChar; MaxLen: Cardinal): Integer; $[SysUtils.pas
功能 返回比較兩個指針字符串指定長度
說明 當S1>S2返回值>0;當S1<S2返回值<0;當S1=S2返回值=0;不區分大小寫
參考 function Windows.CompareString
例子 SpinEdit1.Value := AnsiStrLIComp(PChar(Edit1.Text), PChar(Edit2.Text), SpinEdit2.Value)
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiStrLower(Str: PChar): PChar; $[SysUtils.pas
功能 返回指針字符串小寫形式
說明 非大寫字符不處理
參考 function Windows.CharLower
例子 Edit2.Text := AnsiStrLower(PChar(Edit1.Text));
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiStrUpper(Str: PChar): PChar; $[SysUtils.pas
功能 返回指針字符串大寫形式
說明 非小寫字符不處理
參考 function Windows.CharUpper
例子 Edit2.Text := AnsiStrUpper(PChar(Edit1.Text));
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiLastChar(const S: string): PChar; $[SysUtils.pas
功能 返回字符串S的最後一個指針字符
說明 當字符串S爲空串則返回空指針
參考 function SysUtils.ByteType
例子 Edit2.Text := AnsiLastChar(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiStrLastChar(P: PChar): PChar; $[SysUtils.pas
功能 返回指針字符串P的最後一個指針字符
說明 當字符串P爲空空指針則返回空指針
參考 function SysUtils.ByteType
例子 Edit2.Text := AnsiLastChar(PChar(Edit1.Text));
━━━━━━━━━━━━━━━━━━━━━
首部 function WideUpperCase(const S: WideString): WideString; $[SysUtils.pas
功能 返回雙字節字符串的大寫形式
說明 WideChar雙字節字符
參考 function Windows.CharUpperBuffW
例子 Edit2.Text := WideUpperCase(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function WideLowerCase(const S: WideString): WideString; $[SysUtils.pas
功能 返回雙字節字符串的小寫形式
說明 我怎麽就測試不出來呢
參考 function Windows.CharLowerBuffW
例子 Edit2.Text := WideLowerCase(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function WideCompareStr(const S1, S2: WideString): Integer; $[SysUtils.pas
功能 返回比較兩個雙字節字符串
說明 當S1>S2返回值>0;當S1<S2返回值<0;當S1=S2返回值=0;區分大小寫
參考 function Windows.CompareStringW
例子 SpinEdit1.Value := WideCompareStr(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function WideSameStr(const S1, S2: WideString): Boolean; $[SysUtils.pas
功能 返回兩個雙字節字符串是否相同
說明 區分大小寫
參考 function SysUtils.WideCompareStr
例子 CheckBox1.Checked := WideSameStr(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function WideCompareText(const S1, S2: WideString): Integer; $[SysUtils.pas
功能 返回比較兩個雙字節字符串
說明 當S1>S2返回值>0;當S1<S2返回值<0;當S1=S2返回值=0;不區分大小寫
參考 function Windows.CompareStringW
例子 SpinEdit1.Value := WideCompareText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function WideSameText(const S1, S2: WideString): Boolean; $[SysUtils.pas
功能 返回兩個雙字節字符串是否相同
說明 不區分大小寫
參考 function SysUtils.WideCompareText
例子 CheckBox1.Checked := WideSameText(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function Trim(const S: string): string; overload; $[SysUtils.pas
首部 function Trim(const S: WideString): WideString; overload; $[SysUtils.pas
功能 返回除去字符串S左右不可見字符
說明 小于#32的字符看作不可見字符
參考 function System.Copy
例子 Edit2.Text := Trim(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function TrimLeft(const S: string): string; overload; $[SysUtils.pas
首部 function TrimLeft(const S: WideString): WideString; overload; $[SysUtils.pas
功能 返回除去字符串S左邊不可見字符
說明 小于#32的字符看作不可見字符
參考 function System.Copy
例子 Edit2.Text := TrimLeft(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function TrimRight(const S: string): string; overload; $[SysUtils.pas
首部 function TrimRight(const S: WideString): WideString; overload; $[SysUtils.pas
功能 返回除去字符串S右邊不可見字符
說明 小于#32的字符看作不可見字符
參考 function System.Copy
例子 Edit2.Text := TrimRight(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function QuotedStr(const S: string): string; $[SysUtils.pas
功能 返回字符串S在pascal中的表現形式
說明 單引號中的一個單引號將轉成兩個
參考 procedure System.Insert
例子 Edit2.Text := QuotedStr(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiQuotedStr(const S: string; Quote: Char): string; $[SysUtils.pas
功能 返回字符串S以字符Quote爲引號的表現形式
說明 AnsiQuotedStr('hello"world', '@')='@hello"world@';AnsiQuotedStr('hello"world', '"')='"hello""world"'
參考 function SysUtils.AnsiStrScan
例子 Edit2.Text := AnsiQuotedStr(Edit1.Text, '"');
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiExtractQuotedStr(var Src: PChar; Quote: Char): string; $[SysUtils.pas
功能 返回以字符Quote爲引號的表現形式原形
說明 表現形式非法時Src不變否則爲空
參考 function SysUtils.AnsiStrScan
例子
///////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
━━━━━━━━━━━━━━━━━━━━━
首部 function AnsiDequotedStr(const S: string; AQuote: Char): string; $[SysUtils.pas
功能 返回以字符AQuote爲引號的表現形式原形
說明 表現形式非法時則返回S
參考 function SysUtils.AnsiExtractQuotedStr
例子 Edit2.Text := AnsiDequotedStr(Edit1.Text, '"');
━━━━━━━━━━━━━━━━━━━━━
首部 function AdjustLineBreaks(const S: string; Style: TTextLineBreakStyle = {$IFDEF LINUX} tlbsLF {$ENDIF} {$IFDEF MSWINDOWS} tlbsCRLF {$ENDIF}): string; $[SysUtils.pas
功能 返回將給定字符串的行分隔符調整爲CR/LF序列
說明 AdjustLineBreaks('1'#13'2'#13)='1'#13#10'2'#13#10;AdjustLineBreaks('1'#10'2'#10)='1'#13#10'2'#13#10
參考 function SysUtils.StrNextChar
例子 <NULL>
━━━━━━━━━━━━━━━━━━━━━
首部 function IsValidIdent(const Ident: string): Boolean; $[SysUtils.pas
功能 返回字符串Ident是否是正確的標識符
說明 標識符::字母|下劃線[字母|下劃線|數字]...
參考 <NULL>
例子 CheckBox1.Checked := IsValidIdent(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function IntToStr(Value: Integer): string; overload; $[SysUtils.pas
首部 function IntToStr(Value: Int64): string; overload; $[SysUtils.pas
功能 返回整數Value轉換成字符串
說明 Format('%d', [Value])
參考 function SysUtils.FmtStr
例子 Edit2.Text := IntToStr(SpinEdit1.Value);
━━━━━━━━━━━━━━━━━━━━━
首部 function IntToHex(Value: Integer; Digits: Integer): string; overload; $[SysUtils.pas
首部 function IntToHex(Value: Int64; Digits: Integer): string; overload; $[SysUtils.pas
功能 返回整數Value轉換成十六進制表現結果;Format('%.*x', [Digits, Value])
說明 參數Digits指定字符最小寬度;最小寬度不足時將用0填充
參考 function SysUtils.FmtStr
例子 Edit2.Text := IntToHex(SpinEdit1.Value, SpinEdit2.Value);
━━━━━━━━━━━━━━━━━━━━━
首部 function StrToInt(const S: string): Integer; $[SysUtils.pas
功能 返回字符串S轉換成整數
說明 字符串非整數表達時將引起異常
參考 procedure System.Val
例子 SpinEdit1.Value := StrToInt(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function StrToIntDef(const S: string; Default: Integer): Integer; $[SysUtils.pas
功能 返回字符串S轉換成整數
說明 字符串非整數表達時則返回默認值Default
參考 procedure System.Val
例子 SpinEdit1.Value := StrToIntDef(Edit1.Text, 0);
━━━━━━━━━━━━━━━━━━━━━
首部 function TryStrToInt(const S: string; out Value: Integer): Boolean; $[SysUtils.pas
功能 返回字符串S轉換成整數Value是否成功
說明 字符串非整數表達時返回False並且Value將輸出爲0
參考 procedure System.Val
例子
///////Begin TryStrToInt
procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
begin
CheckBox1.Checked := TryStrToInt(Edit1.Text, I);
SpinEdit1.Value := I;
end;
///////End TryStrToInt
━━━━━━━━━━━━━━━━━━━━━
首部 function StrToInt64(const S: string): Int64; $[SysUtils.pas
功能 返回字符串S轉換成六十四位整數
說明 字符串非六十四位整數表達時將引起異常
參考 procedure System.Val
例子 SpinEdit1.Value := StrToInt64(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function StrToInt64Def(const S: string; const Default: Int64): Int64; $[SysUtils.pas
功能 返回字符串S轉換成六十四位整數
說明 字符串非六十四位整數表達時則返回默認值Default
參考 procedure System.Val
例子 SpinEdit1.Value := StrToInt64Def(Edit1.Text, 0);
━━━━━━━━━━━━━━━━━━━━━
首部 function TryStrToInt64(const S: string; out Value: Int64): Boolean; $[SysUtils.pas
功能 返回字符串S轉換成六十四位整數Value是否成功
說明 字符串非六十四位整數表達時返回False並且Value將輸出爲0
參考 procedure System.Val
例子
///////Begin TryStrToInt64
procedure TForm1.Button1Click(Sender: TObject);
var
I: Int64;
begin
CheckBox1.Checked := TryStrToInt64(Edit1.Text, I);
SpinEdit1.Value := I;
end;
///////End TryStrToInt64
━━━━━━━━━━━━━━━━━━━━━
首部 function StrToBool(const S: string): Boolean; $[SysUtils.pas
功能 返回字符串S轉換成邏輯值
說明 字符非邏輯表達時將引起異常
參考 function SysUtils.TryStrToBool
例子 CheckBox1.Checked := StrToBool(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function StrToBoolDef(const S: string; const Default: Boolean): Boolean; $[SysUtils.pas
功能 返回字符串S轉換成邏輯值
說明 字符非邏輯表達時則返回默認值Default
參考 function SysUtils.TryStrToBool
例子 CheckBox1.Checked := StrToBoolDef(Edit1.Text, False);
━━━━━━━━━━━━━━━━━━━━━
首部 function TryStrToBool(const S: string; out Value: Boolean): Boolean; $[SysUtils.pas
功能 返回字符串S轉換成邏輯值Value是否成功
說明 [注意]0爲假非0爲真;不是'True'和'False';Delphi6 Bug 如下修正
參考 function SysUtils.AnsiSameText;var SysUtils.TrueBoolStrs;var SysUtils.FalseBoolStrs
例子
///////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
附加
///////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 Result then
Value := LResult <> 0
else
begin
Result := True; //修正處
VerifyBoolStrArray;
if CompareWith(TrueBoolStrs) then
Value := True
else if CompareWith(FalseBoolStrs) then
Value := False
else
Result := False;
end;
end;
///////End TryStrToBool
━━━━━━━━━━━━━━━━━━━━━
首部 function BoolToStr(B: Boolean; UseBoolStrs: Boolean = False): string; $[SysUtils.pas
功能 返回邏輯值B轉換成字符串
說明 BoolToStr(False, False)='0';BoolToStr(False, True)='-1'
參考 var SysUtils.TrueBoolStrs;var SysUtils.FalseBoolStrs
例子 Edit1.Text := BoolToStr(CheckBox1.Checked, CheckBox2.Checked);
━━━━━━━━━━━━━━━━━━━━━
首部 function LoadStr(Ident: Integer): string; $[SysUtils.pas
功能 返回根據標識Ident的字符串資源
說明 字符串資源是指程序的內部資源
參考 function SysUtils.FindStringResource
例子 Edit2.Text := LoadStr(StrToIntDef(Edit1.Text, 0));
━━━━━━━━━━━━━━━━━━━━━
首部 function FmtLoadStr(Ident: Integer; const Args: array of const): string; $[SysUtils.pas
功能 返回格式化的字符串資源
說明 字符串資源是指程序的內部資源
參考 function SysUtils.FmtStr;function SysUtils.FindStringResource
例子 <NULL>;
━━━━━━━━━━━━━━━━━━━━━
首部 function FileOpen(const FileName: string; Mode: LongWord): Integer; $[SysUtils.pas
功能 返回打開文件果
說明 Mode指定打開文件的模式(fmOpenRead,fmOpenWrite,fmOpenReadWrite....);打開失敗則返回負數
參考 function Windows.CreateFile
例子
///////Begin FileOpen,FileClose
procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
begin
I := FileOpen(Edit1.Text, fmOpenRead);
CheckBox1.Checked := I > 0;
FileClose(I);
end;
///////Begin FileOpen,FileClose
━━━━━━━━━━━━━━━━━━━━━
首部 function FileCreate(const FileName: string): Integer; overload; $[SysUtils.pas
首部 function FileCreate(const FileName: string; Rights: Integer): Integer; overload; $[SysUtils.pas
功能 返回創建文件
說明 創建失敗則返回負數
參考 function Windows.CreateFile
例子
///////Begin FileCreate
procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
begin
I := FileCreate(Edit1.Text);
CheckBox1.Checked := I > 0;
FileClose(I);
end;
///////End FileCreate
━━━━━━━━━━━━━━━━━━━━━
首部 function FileRead(Handle: Integer; var Buffer; Count: LongWord): Integer; $[SysUtils.pas
功能 返回讀取文件緩沖區的大小
說明 讀取失敗則返回負數
參考 function Windows.ReadFile
例子 <參見FileOpen>
━━━━━━━━━━━━━━━━━━━━━
首部 function FileWrite(Handle: Integer; const Buffer; Count: LongWord): Integer; $[SysUtils.pas
功能 返回寫入文件緩沖區的大小
說明 寫入失敗則返回負數
參考 function Windows.WriteFile
例子 <參見FileCreate>
━━━━━━━━━━━━━━━━━━━━━
首部 function FileSeek(Handle, Offset, Origin: Integer): Integer; overload; $[SysUtils.pas
首部 function FileSeek(Handle: Integer; const Offset: Int64; Origin: Integer): Int64; overload; $[SysUtils.pas
功能 返回指定文件偏移量
說明 Offset指定偏移量;Origin指定原點(Origin爲0時指文件首;爲1時指當前位置;爲2時指文件尾)
參考 function Windows.SetFilePointer
例子 <參見FileOpen>
━━━━━━━━━━━━━━━━━━━━━
首部 procedure FileClose(Handle: Integer); $[SysUtils.pas
功能 返回關閉文件
說明 不關閉打開的文件會占用系統資源
參考 function Windows.CloseHandle
例子 <參見FileOpen>
━━━━━━━━━━━━━━━━━━━━━
首部 function FileAge(const FileName: string): Integer; $[SysUtils.pas
功能 返回文件創建的時間
說明 文件不存在則返回-1
參考 function Windows.FindFirstFile
例子
///////Begin FileAge,DateTimeToStr,FileDateToDateTime
procedure TForm1.Button1Click(Sender: TObject);
begin
SpinEdit1.Value := FileAge(Edit1.Text);
if SpinEdit1.Value > 0 then
Edit2.Text := DateTimeToStr(FileDateToDateTime(SpinEdit1.Value));
end;
///////End FileAge,DateTimeToStr,FileDateToDateTime
━━━━━━━━━━━━━━━━━━━━━
首部 function FileExists(const FileName: string): Boolean; $[SysUtils.pas
功能 返回文件名FileName是否有實體存在
說明 包括隱藏文件
參考 function SysUtils.FileAge
例子 CheckBox1.Checked := FileExists(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function DirectoryExists(const Directory: string): Boolean; $[SysUtils.pas
功能 返回目錄名FileName是否有實體存在
說明 包括隱藏目錄
參考 function Windows.GetFileAttributes
例子 CheckBox1.Checked := DirectoryExists(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function ForceDirectories(Dir: string): Boolean; $[SysUtils.pas
功能 返回創建子目錄是否成功
說明 直接創建多級目錄
參考 function SysUtils.CreateDir
例子 CheckBox1.Checked := ForceDirectories(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function FindFirst(const Path: string; Attr: Integer; var F: TSearchRec): Integer; $[SysUtils.pas
功能 返回設置文件搜索
說明 搜索成功則返回0
參考 function Windows.FindFirstFile
例子
///////Begin FindFirst,FindNext,FindClose
procedure TForm1.Button1Click(Sender: TObject);
var
vSearchRec: TSearchRec;
I: Integer;
begin
Memo1.Clear;
I := FindFirst(Edit1.Text, faAnyFile, vSearchRec);
while I = 0 do begin
Memo1.Lines.Add(vSearchRec.Name);
I := FindNext(vSearchRec);
end;
FindClose(vSearchRec);
end;
///////End FindFirst,FindNext,FindClose
━━━━━━━━━━━━━━━━━━━━━
首部 function FindNext(var F: TSearchRec): Integer; $[SysUtils.pas
功能 返回繼續文件搜索
說明 搜索成功則返回0
參考 function Windows.FindNextFile
例子 <參見FindFirst>
━━━━━━━━━━━━━━━━━━━━━
首部 procedure FindClose(var F: TSearchRec); $[SysUtils.pas
功能 結束當前文件搜索
說明 不關閉查詢會占用系統資源
參考 function Windows.FindClose
例子 <參見FindFirst>
━━━━━━━━━━━━━━━━━━━━━
首部 function FileGetDate(Handle: Integer): Integer; $[SysUtils.pas
功能 返回文件的修改時間
說明 讀取失敗則返回-1
參考 function Windows.GetFileTime
例子
///////Begin FileGetDate
procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
begin
I := FileOpen(Edit1.Text, fmOpenRead);
if I < 0 then Exit;
SpinEdit1.Value := FileGetDate(I);
Edit2.Text := DateTimeToStr(FileDateToDateTime(SpinEdit1.Value));
FileClose(I);
end;
///////End FileGetDate
━━━━━━━━━━━━━━━━━━━━━
首部 function FileSetDate(const FileName: string; Age: Integer): Integer; overload; $[SysUtils.pas
首部 function FileSetDate(Handle: Integer; Age: Integer): Integer; overload; platform; $[SysUtils.pas
功能 返回設置文件的修改時間
說明 修改成功則返回0
參考 function Windows.SetFileTime
例子 SpinEdit1.Value := FileSetDate(Edit1.Text, DateTimeToFileDate(StrToDateTime(Edit2.Text)));
━━━━━━━━━━━━━━━━━━━━━
首部 function FileGetAttr(const FileName: string): Integer; platform; $[SysUtils.pas
功能 返回文件的屬性
說明 讀取失敗則返回$FFFFFFFF
參考 function Windows.GetFileAttributes
例子 SpinEdit1.Value := FileGetAttr(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function FileSetAttr(const FileName: string; Attr: Integer): Integer; platform; $[SysUtils.pas
功能 返回設置文件的屬性
說明 設置成功則返回0
參考 function Windows.SetFileAttributes
例子 SpinEdit1.Value := FileSetAttr(Edit1.Text, SpinEdit2.Value);
━━━━━━━━━━━━━━━━━━━━━
首部 function FileIsReadOnly(const FileName: string): Boolean; $[SysUtils.pas
功能 返回文件是否只讀
說明 文件不存在看作只讀
參考 function Windows.GetFileAttributes
例子 CheckBox1.Checked := FileIsReadOnly(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function FileSetReadOnly(const FileName: string; ReadOnly: Boolean): Boolean; $[SysUtils.pas
功能 返回設置文件是否只讀是否成功
說明 文件不存在則返回False
參考 function Windows.GetFileAttributes;function Windows.SetFileAttributes
例子 CheckBox1.Checked := FileSetReadOnly(Edit1.Text, CheckBox2.Checked);
━━━━━━━━━━━━━━━━━━━━━
首部 function DeleteFile(const FileName: string): Boolean; $[SysUtils.pas
功能 返回刪除文件是否成功
說明 文件不存在則返回False
參考 function Windows.DeleteFile
例子 CheckBox1.Checked := DeleteFile(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function RenameFile(const OldName, NewName: string): Boolean; $[SysUtils.pas
功能 返回重命名文件是否成功
說明 文件不存在則返回False
參考 function Windows.MoveFile
例子 CheckBox1.Checked := RenameFile(Edit1.Text, Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function ChangeFileExt(const FileName, Extension: string): string; $[SysUtils.pas
功能 返回改變擴展名後的文件名
說明 [注意]擴展名Extension前要加點;ChangeFileExt('a.jpg', 'bmp')='abmp'
參考 function SysUtils.LastDelimiter;function System.Copy
例子 Edit1.Text := ChangeFileExt(Edit2.Text, Edit3.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function ExtractFilePath(const FileName: string): string; $[SysUtils.pas
功能 返回文件名所在的路徑
說明 ExtractFilePath('C:\')='C:\';ExtractFilePath('\\Server\Tool\Calc.exe')='\\Server\Tool\'
參考 function SysUtils.LastDelimiter;function System.Copy
例子 Edit1.Text := ExtractFilePath(Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function ExtractFileDir(const FileName: string): string; $[SysUtils.pas
功能 返回文件名所在的目錄
說明 ExtractFileDir('C:\')='C:\';ExtractFileDir('\\Server\Tool\Calc.exe')='\\Server\Tool'
參考 function SysUtils.LastDelimiter;function System.Copy
例子 Edit1.Text := ExtractFileDir(Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function ExtractFileDrive(const FileName: string): string; $[SysUtils.pas
功能 返回文件名所在驅動器
說明 ExtractFileDrive('C:\')='C:';ExtractFileDrive('\\Server\Tool\Calc.exe')='\\Server\Tool'
參考 function System.Copy
例子 Edit1.Text := ExtractFileDrive(Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function ExtractFileName(const FileName: string): string; $[SysUtils.pas
功能 返回絕對文件名
說明 ExtractFileName('C:\')='';ExtractFileName('\\Server\Tool\Calc.exe')='Calc.exe'
參考 function SysUtils.LastDelimiter;function System.Copy
例子 Edit1.Text := ExtractFileName(Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function ExtractFileExt(const FileName: string): string; $[SysUtils.pas
功能 返回文件名的擴展名
說明 ExtractFileExt('C:\')='';ExtractFileExt('\\Server\Tool\Calc.exe')='.exe'
參考 function SysUtils.LastDelimiter;function System.Copy
例子 Edit1.Text := ExtractFileExt(Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function ExpandFileName(const FileName: string): string; $[SysUtils.pas
功能 返回文件名的完整表示
說明 ExpandFileName('hello.pas')='C:\Program Files\Borland\Delphi6\Projects\hello.pas'
參考 function Windows.GetFullPathName
例子 Edit1.Text := ExpandFileName(Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function ExpandFileNameCase(const FileName: string; out MatchFound: TFilenameCaseMatch): string; $[SysUtils.pas
功能 分情況返回文件名的完整表示
說明 type TFilenameCaseMatch = (mkNone, mkExactMatch, mkSingleMatch, mkAmbiguous);
參考 function Windows.GetFullPathName;function SysUtils.SameFileName;function SysUtils.FindFirst
例子
///////Begin ExpandFileNameCase
procedure TForm1.Button1Click(Sender: TObject);
var
vFilenameCaseMatch: TFilenameCaseMatch;
begin
Edit1.Text := ExpandFileNameCase(Edit2.Text, vFilenameCaseMatch);
SpinEdit1.Value := Ord(vFilenameCaseMatch);
end;
///////End ExpandFileNameCase
━━━━━━━━━━━━━━━━━━━━━
首部 function ExpandUNCFileName(const FileName: string): string; $[SysUtils.pas
功能 返回LINUX文件名的完整表示
說明 ExpandUNCFileName('C:/')='C:\'
參考 function SysUtils.ExpandFileName
例子 Edit1.Text := ExpandUNCFileName(Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function ExtractRelativePath(const BaseName, DestName: string): string; $[SysUtils.pas
功能 返回參數的相對路徑
說明 ExtractRelativePath('C:\Windows\', 'C:\Windows\System')='System'
參考 function SysUtils.SameFilename;function SysUtils.ExtractFileDrive
例子 Edit1.Text := ExtractRelativePath(Edit2.Text, Edit3.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function ExtractShortPathName(const FileName: string): string; $[SysUtils.pas
功能 返回參數的DOS路徑
說明 ExtractShortPathName('C:\Program Files\Borland')='C:\PROGRA~1\BORLAND'
參考 function Windows.GetShortPathName
例子 Edit1.Text := ExtractShortPathName(Edit2.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function FileSearch(const Name, DirList: string): string; $[SysUtils.pas
功能 返回目錄列表中DirList搜索的第一個結果
說明 FileSearch('Calc.exe', 'd:\winxp\system32;c:\windows')='d:\winxp\system32\calc.exe'
參考 function SysUtils.FileExists;function SysUtils.AnsiLastChar
例子 Edit1.Text := FileSearch(Edit2.Text, Edit3.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function DiskFree(Drive: Byte): Int64; $[SysUtils.pas
功能 返回驅動器可用空間
說明 參數Drive爲0表示當前路徑,爲1表示=A驅,爲2表示=B驅...;獲取失敗則返回-1
參考 function Windows.GetDiskFreeSpaceExA
例子 SpinEdit1.Value := DiskFree(SpinEdit2.Value);
━━━━━━━━━━━━━━━━━━━━━
首部 function DiskSize(Drive: Byte): Int64; $[SysUtils.pas
功能 返回驅動器全部空間
說明 參數Drive爲0表示當前路徑,爲1表示=A驅,爲2表示=B驅...;獲取失敗則返回-1
參考 function Windows.GetDiskFreeSpaceExA
例子 SpinEdit1.Value := DiskSize(SpinEdit2.Value);
━━━━━━━━━━━━━━━━━━━━━
首部 function FileDateToDateTime(FileDate: Integer): TDateTime; $[SysUtils.pas
功能 返回將文件日期時間類型轉換日期時間類型
說明 FileDate非法是將觸發異常
參考 function SysUtils.EncodeDate;function SysUtils.EncodeTime
例子 <參見FileAge>
━━━━━━━━━━━━━━━━━━━━━
首部 function DateTimeToFileDate(DateTime: TDateTime): Integer; $[SysUtils.pas
功能 返回將日期時間類型轉換文件日期時間類型
說明 年份在1980到2107之外則返回0
參考 function SysUtils.DecodeDate;function SysUtils.DecodeTime
例子 <參見FileSetDate>
━━━━━━━━━━━━━━━━━━━━━
首部 function GetCurrentDir: string; $[SysUtils.pas
功能 返回當前操作目錄
說明 [注意]調用文件對話框會改變當前操作目錄
參考 function System.GetDir
例子 Edit1.Text := GetCurrentDir;
━━━━━━━━━━━━━━━━━━━━━
首部 function SetCurrentDir(const Dir: string): Boolean; $[SysUtils.pas
功能 返回設置當前操作目錄是否成功
說明 [注意]調用文件對話框會改變當前操作目錄
參考 function Windows.SetCurrentDirectory
例子 CheckBox1.Checked := SetCurrentDir(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function CreateDir(const Dir: string): Boolean; $[SysUtils.pas
功能 返回創建目錄是否成功
說明 不支持多級目錄;已經存在則返回False
參考 function Windows.CreateDirectory
例子 CheckBox1.Checked := CreateDir(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function RemoveDir(const Dir: string): Boolean; $[SysUtils.pas
功能 返回刪除目錄是否成功
說明 必須是空目錄
參考 function Windows.RemoveDirectory
例子 CheckBox1.Checked := RemoveDir(Edit1.Text);
━━━━━━━━━━━━━━━━━━━━━
首部 function StrLen(const Str: PChar): Cardinal; $[SysUtils.pas
功能 返回指針字符串的長度
說明 當指針字符串Str爲nil時將觸發異常
參考 <NULL>
例子 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
例子
///////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>
例子
///////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>
例子
///////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>
例子
///////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
例子
///////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
例子
///////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
例子
///////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>
例子
///////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(Edit2.Text));
━━━━━━━━━━━━━━━━━━━━━
首部 function StrUpper(Str: PChar): PChar; $[SysUtils.pas
功能 返回指針字符串Str大寫
說明 非小寫字符不處理
參考 <NULL>
例子 Edit1.Text := StrUpper(PChar(Edit2.Text));
━━━━━━━━━━━━━━━━━━━━━
首部 function StrLower(Str: PChar): PChar; $[SysUtils.pas
功能 返回指針字符串Str小寫
說明 非大寫字符不處理
參考 <NULL>
例子 Edit1.Text := StrLower(PChar(Edit2.Text));
━━━━━━━━━━━━━━━━━━━━━
首部 function StrPas(const Str: PChar): string; $[SysUtils.pas
功能 返回指針字符串Str轉換成字符串
說明 也可以直接賦值
參考 <NULL>
例子 Edit1.Text := StrPas(PChar(Edit2.Text));
━━━━━━━━━━━━━━━━━━━━━
首部 function StrAlloc(Size: Cardinal): PChar; $[SysUtils.pas
功能 返回分配指定空間的內存資源給指針字符串
說明 空間的大小也將保存;用StrDispose才能全部釋放
參考 function System.GetMem
例子
///////Begin StrAlloc
procedure TForm1.Button1Click(Sender: TObject);
var
P: PChar;
begin
P := StrAlloc(SpinEdit1.Value);
ShowMessage(IntToStr(StrLen(P)));
Dec(P, SizeOf(Cardinal));
ShowMessage(IntToStr(Cardinal(Pointer(P)^)));
Inc(P, SizeOf(Cardinal));
StrDispose(P);
end;
///////End StrAlloc
━━━━━━━━━━━━━━━━━━━━━
首部 function StrBufSize(const Str: PChar): Cardinal; $[SysUtils.pas
功能 返回通過函數StrAlloc分配的緩沖區大小
說明 出現異常情況則返回不可預知的結果
參考 function System.SizeOf
例子 SpinEdit1.Value := StrBufSize(StrAlloc(SpinEdit2.Value));
━━━━━━━━━━━━━━━━━━━━━
首部 function StrNew(const Str: PChar): PChar; $[SysUtils.pas
功能 返回複制一個新的指針字符串
說明 如果Str爲nil則返回nil
參考 function SysUtils.StrLen;function SysUtils.StrMove;function SysUtils.StrAlloc
例子
///////Begin StrNew,StrDispose
procedure TForm1.Button1Click(Sender: TObject);
var
P: PChar;
begin
P := StrNew(PChar(Edit1.Text));
ShowMessage(P);
StrDispose(P);
end;
///////End StrNew,StrDispose
━━━━━━━━━━━━━━━━━━━━━
首部 procedure StrDispose(Str: PChar); $[SysUtils.pas
功能 釋放指針字符串Str內存資源
說明 如果Str爲nil則不作任何處理;並且釋放空間大小信息
參考 function System.Dec;function System.SizeOf;function System.FreeMem
例子 <參見StrNew>
━━━━━━━━━━━━━━━━━━━━━
首部 function Format(const Format: string; const Args: array of const): string; $[SysUtils.pas
功能 返回按指定方式格式化一個數組常量的字符形式
說明 這個函數是我在Delphi中用得最多的函數,現在就列舉幾個例子給你個直觀的理解
"%" [索引 ":"] ["-"] [寬度] ["." 摘要] 類型
Format('x=%d', [12]); //'x=12' //最普通
Format('x=%3d', [12]); //'x= 12' //指定寬度
Format('x=%f', [12.0]); //'x=12.00' //浮點數
Format('x=%.3f', [12.0]); //'x=12.000' //指定小數
Format('x=%.*f', [5, 12.0]); //'x=12.00000' //動態配置
Format('x=%.5d', [12]); //'x=00012' //前面補充0
Format('x=%.5x', [12]); //'x=0000C' //十六進制
Format('x=%1:d%0:d', [12, 13]); //'x=1312' //使用索引
Format('x=%p', [nil]); //'x=00000000' //指針
Format('x=%1.1e', [12.0]); //'x=1.2E+001' //科學記數法
Format('x=%%', []); //'x=%' //得到"%"
S := Format('%s%d', [S, I]); //S := S + StrToInt(I); //連接字符串
參考 proceduer SysUtils.FmtStr
例子 Edit1.Text := Format(Edit2.Text, [StrToFloatDef(Edit.3.Text, 0)]);
━━━━━━━━━━━━━━━━━━━━━
首部 procedure FmtStr(var Result: string; const Format: string; const Args: array of const); $[SysUtils.pas
功能 按指定方式格式化一個數組常量的字符形式返回
說明 <參見Format>
參考 function SysUtils.FormatBuf;function System.Length;function System.SetLength
例子 <參見Format>
━━━━━━━━━━━━━━━━━━━━━
首部 function StrFmt(Buffer, Format: PChar; const Args: array of const): PChar; $[SysUtils.pas
功能 返回按指定方式格式化一個數組常量的字符指針形式
說明 如果Buffer和Format其中只要有一個爲nil則返回nil
參考 function SysUtils.FormatBuf
例子 <參見Format>
━━━━━━━━━━━━━━━━━━━━━
首部 function StrLFmt(Buffer: PChar; MaxBufLen: Cardinal; Format: PChar; const Args: array of const): PChar; $[SysUtils.pas
功能 返回按指定方式和長度格式化一個數組常量的字符指針形式
說明 StrLFmt(vBuffer, 6, '%d|12345', [1024]) = '1024|1';
參考 function SysUtils.FormatBuf
例子 <參見Format>
━━━━━━━━━━━━━━━━━━━━━
首部 function FormatBuf(var Buffer; BufLen: Cardinal; const Format; FmtLen: Cardinal; const Args: array of const): Cardinal; $[SysUtils.pas
功能 返回按指定方式格式化一個數組常量到緩沖區Buffer中
說明 <NULL>
參考 <NULL>
例子 <參見Format>
━━━━━━━━━━━━━━━━━━━━━
首部 function WideFormat(const Format: WideString; const Args: array of const): WideString; $[SysUtils.pas
功能 返回按指定方式格式化一個數組常量的多字節字符形式
說明 <NULL>
參考 procedure SysUtils.WideFmtStr
例子 <參見Format>
━━━━━━━━━━━━━━━━━━━━━
首部 procedure WideFmtStr(var Result: WideString; const Format: WideString; const Args: array of const); $[SysUtils.pas
功能 按指定方式格式化一個數組常量的多字節字符形式返回
說明 <NULL>
參考 function SysUtils.WideFormatBuf
例子 <參見Format>
━━━━━━━━━━━━━━━━━━━━━
首部 function WideFormatBuf(var Buffer; BufLen: Cardinal; const Format; FmtLen: Cardinal; const Args: array of const): Cardinal; $[SysUtils.pas
功能 返回按指定方式格式化一個數組常量到緩沖區Buffer中
說明 <NULL>
參考 <NULL>
例子 <參見Format>
━━━━━━━━━━━━━━━━━━━━━
首部 function FloatToStr(Value: Extended): string; $[SysUtils.pas
功能 返回浮點數Value轉換成字符串
說明 當浮點數大等于1E15將采用科學記數法
參考 function SysUtils.FloatToText
例子 Edit1.Text := FloatToStr(Now);
━━━━━━━━━━━━━━━━━━━━━
首部 function CurrToStr(Value: Currency): string; $[SysUtils.pas
功能 返回貨幣數Value轉換成字符串
說明 貨幣數只保留四位小數
參考 function SysUtils.FloatToText
例子 Edit1.Text := CurrToStr(Now);
━━━━━━━━━━━━━━━━━━━━━
首部 function FloatToCurr(const Value: Extended): Currency; $[SysUtils.pas
功能 返回浮點數Value轉換成貨幣數
說明 如果浮點數Value超出範圍則將觸發異常
參考 const SysUtiles.MinCurrency;const SysUtiles.MaxCurrency
例子 Edit1.Text := CurrToStr(FloatToCurr(Now));
━━━━━━━━━━━━━━━━━━━━━
首部 function FloatToStrF(Value: Extended; Format: TFloatFormat; Precision, Digits: Integer): string; $[SysUtils.pas
功能 返回浮點數以指定格式轉換成字符串
說明 Precision指定精度;Digits指定小數寬度
參考 function SysUtils.FloatToText
例子
///////Begin FloatToStrF
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Lines.Values['ffGeneral'] := FloatToStrF(StrToFloatDef(Edit1.Text, 0),
ffGeneral, SpinEdit1.Value, SpinEdit2.Value);
Memo1.Lines.Values['ffExponent'] := FloatToStrF(StrToFloatDef(Edit1.Text, 0),
ffExponent, SpinEdit1.Value, SpinEdit2.Value);
Memo1.Lines.Values['ffFixed'] := FloatToStrF(StrToFloatDef(Edit1.Text, 0),
ffFixed, SpinEdit1.Value, SpinEdit2.Value);
Memo1.Lines.Values['ffNumber'] := FloatToStrF(StrToFloatDef(Edit1.Text, 0),
ffNumber, SpinEdit1.Value, SpinEdit2.Value);
Memo1.Lines.Values['ffCurrency'] := FloatToStrF(StrToFloatDef(Edit1.Text, 0),
ffCurrency, SpinEdit1.Value, SpinEdit2.Value);
end;
///////End FloatToStrF
━━━━━━━━━━━━━━━━━━━━━
首部 function CurrToStrF(Value: Currency; Format: TFloatFormat; Digits: Integer): string; $[SysUtils.pas
功能 返回貨幣類型以指定格式轉換成字符串
說明 Digits指定小數寬度
參考 function SysUtils.FloatToText
例子
///////Begin CurrToStrF
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Lines.Values['ffGeneral'] := CurrToStrF(StrToCurrDef(Edit1.Text, 0),
ffGeneral, SpinEdit1.Value);
Memo1.Lines.Values['ffExponent'] := CurrToStrF(StrToCurrDef(Edit1.Text, 0),
ffExponent, SpinEdit1.Value);
Memo1.Lines.Values['ffFixed'] := CurrToStrF(StrToCurrDef(Edit1.Text, 0),
ffFixed, SpinEdit1.Value);
Memo1.Lines.Values['ffNumber'] := CurrToStrF(StrToCurrDef(Edit1.Text, 0),
ffNumber, SpinEdit1.Value);
Memo1.Lines.Values['ffCurrency'] := CurrToStrF(StrToCurrDef(Edit1.Text, 0),
ffCurrency, SpinEdit1.Value);
end;
///////End CurrToStrF
━━━━━━━━━━━━━━━━━━━━━
首部 function FloatToText(BufferArg: PChar; const Value; ValueType: TFloatValue; Format: TFloatFormat; Precision, Digits: Integer): Integer; $[SysUtils.pas
功能 返回浮點數以指定格式轉換成指針字符串的內存大小
說明 Precision指定精度;Digits指定小數寬度
參考 <NULL>
例子
///////Begin FloatToText
procedure TForm1.Button1Click(Sender: TObject);
var
vBuffer: array[0..255] of Char;
E: Extended;
begin
E := StrToFloatDef(Edit1.Text, 0);
SpinEdit3.Value := FloatToText(vBuffer, E,
fvExtended, ffNumber, SpinEdit1.Value, SpinEdit2.Value);
Edit2.Text := Copy(vBuffer, 1, SpinEdit3.Value);
end;
///////End FloatToText(