============================================ Floating-point conversion routines 浮点数转换函式 ============================================ FloatToDecimal 将浮点数转换为十进位数. ----------------------------------------------------------------------------- Unit SysUtils 函数原型 procedure FloatToDecimal(var Result: TFloatRec; const Value; ValueType: TFloatValue; Precision, Decimals: Integer); ----------------------------------------------------------------------------- FloatToStrF 将浮点数转换为格式化字串. ----------------------------------------------------------------------------- Unit SysUtils 函数原型 function FloatToStrF(Value: Extended; Format: TFloatFormat; Precision,Digits: Integer): string; ----------------------------------------------------------------------------- FloatToStr 将浮点数转换为字串. ----------------------------------------------------------------------------- Unit SysUtils 函数原型 function FloatToStr(Value: Extended): string; ----------------------------------------------------------------------------- FloatToText 将浮点数转换为格式化十进位. ----------------------------------------------------------------------------- Unit SysUtils 函数原型 function FloatToText(Buffer: PChar; const Value; ValueType: TFloatValue;Format: TFloatFormat; Precision, Digits: Integer): Integer; ----------------------------------------------------------------------------- FloatToTextFmt 将浮点数转换为格式化十进位. ----------------------------------------------------------------------------- Unit SysUtils 函数原型 function FloatToTextFmt(Buffer: PChar; const Value; ValueType: TFloatValue; Format: PChar): Integer; ----------------------------------------------------------------------------- FormatFloat 将浮点数转换为格式化字串. ----------------------------------------------------------------------------- Unit SysUtils 函数原型 function FormatFloat(const Format: string; Value: Extended): string; ----------------------------------------------------------------------------- StrToFloat 将字串转换为浮点数. ----------------------------------------------------------------------------- Unit SysUtils 函数原型 function StrToFloat(const S: string): Extended; 范例 procedure TForm1.Button1Click(Sender: TObject); var Value:Double; S:String; begin S:='''' 1234.56 ''''; Value:=StrToFloat(S); Label1.Caption:=Format(''''转换为 [%9.3f]'''',[Value]); end;
注意 若S字串含有非数字字元,会产生错误讯号. ----------------------------------------------------------------------------- TextToFloat 将 null-terminated 字串转换为浮点数. ----------------------------------------------------------------------------- Unit SysUtils 函数原型 function TextToFloat(Buffer: PChar; var Value; ValueType: TFloatValue): Boolean;
=========================================== Flow-control routines 流程控制常式 =========================================== Break 从 for, while, or repeat 终止跳出. ----------------------------------------------------------------------------- Unit System 函数原型 procedure Break; 范例 var S: string; begin while True do begin ReadLn(S); try if S = '''' then Break; WriteLn(S); finally { do something for all cases } end; end; end; ----------------------------------------------------------------------------- Continue 从 for, while, or repeat 继续执行. ----------------------------------------------------------------------------- Unit System 函数原型 procedure Continue; 范例 var F: File; i: integer; begin for i := 0 to (FileListBox1.Items.Count - 1) do begin try if FileListBox1.Selected[i] then begin if not FileExists(FileListBox1.Items.Strings[i]) then begin MessageDlg(''''File: '''' +FileListBox1.Items.Strings[i] + '''' not found'''', mtError, [mbOk], 0); Continue; end; AssignFile(F, FileListBox1.Items.Strings[i]); Reset(F, 1); ListBox1.Items.Add(IntToStr(FileSize(F))); CloseFile(F); end; finally { do something here } end; end; end; 范例 var F: File; i: Integer; begin for i := 0 to (FileListBox1.Items.Count - 1) do begin try if FileListBox1.Selected[i] then begin if not FileExists(FileListBox1.Items.Strings[i]) then begin MessageDlg(''''File: '''' + FileListBox1.Items.Strings[i] + '''' not found'''', mtError, [mbOk], 0); Continue; end; AssignFile(F, FileListBox1.Items.Strings[i]);
Reset(F, 1); ListBox1.Items.Add(IntToStr(FileSize(F))); CloseFile(F); end; finally { do something here } end; end; end; ## Continue, Items, Selected Example ----------------------------------------------------------------------------- Exit 直接离开一个程序. ----------------------------------------------------------------------------- Unit System 函数原型 procedure Exit; ----------------------------------------------------------------------------- Halt 结束程式返回作业系统. ----------------------------------------------------------------------------- Unit System 函数原型 procedure Halt [ ( Exitcode: Integer) ]; 范例 begin if 1 = 1 then begin if 2 = 2 then begin if 3 = 3 then begin Halt(1); { Halt right