線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:11078
推到 Plurk!
推到 Facebook!

Delphi Function 中文說明函式及簡要範例

 
banson1716
高階會員


發表:55
回覆:182
積分:167
註冊:2002-04-14

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-05-15 13:38:35 IP:218.175.xxx.xxx 未訂閱
Delphi Function 中文說明函式及簡要範例 ▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼ ====================================================================== 數學函數 (Arithmetic Routines) Unit: System ====================================================================== Abs 傳回參數的絕對值。 function Abs(X); ArcTan 傳回正切函數的反函數值。 function ArcTan(X: Real): Real; Cos 傳回餘弦函數值 function Cos(X: Real): Real; (X 以弧度為單位)。 Exp 傳回自然指數值。 function Cos(X: Real): Real; Frac 傳回參數的小數部份。 function Frac(X: Real): Real; Int 傳回參數的整數部份。 function Int(X: Real): Real; Ln 傳回自然對數值。 function Ln(X: Real): Real; Pi 傳回圓周率π的值。 function Pi: Real; Sin 傳回正弦函數值。 function Sin(X: Real): Real; Sqr 傳回參數的平方。 function Sqr(X: Real): (Real); Sqrt 傳回參數的平方根。 function Sqrt(X: Real): Real; =========================================================================== 控制台函數 (Console Routines) =========================================================================== Unit: WinCrt 函數名稱 函數說明 函數語法 =========================================================================== AssignCrt 將文字檔連結到一個控制台視窗。 procedure AssignCrt(var f: Text); ClrEol 清附游標位置到該行最後的所有字元。procedure ClrEol; ClrScr 清附螢幕並重置游標至左上角。 procedure ClrScr; CursorTo 移動游標至給定座標。 procedure CursorTo(X, Y:Integer); DoneWinCrt 結束控制台視窗。 procedure DoneWinCrt; GotoXY 移動游標至給定座標。 procedure GotoXY(X, Y: Byte); InitWinCrt 建立控制台視窗。 procedure InitWinCrt; KeyPressed 判斷是否有一按鍵。 function KeyPressed:Boolean; ReadBuf 從控制台視窗讀入一行。 function ReadBuf(Buffer: Pchar;Count: Word): ReadKey 讀取按鍵字元。 function ReadKey: Char; ScrollTo 捲動控制台視窗至顯示位置。 procedure ScrollTo(X, Y: Integer); TrackCursor 捲動控制台視窗宜到游標可見。procedure TrackCursor; WhereX 傳回游標的X 座標。 function WhereX: Byte; WhereY 傳回游標的Y 標標。 function WhereY: Byte; WriteBuf 寫入一區塊字元到控制台視窗。 procedure WriteBuf WriteChar 寫一個字元到控制台視窗。 procedure WriteChar(CH: Char); ================================================= 日期與時間函數 (Date and Time Routines) Unit: SysUtils ======================================== Date 傳回今天日期。function Date: TDateTime; DateTimeToStr 將時間格式轉為字串。function DateTimeToStr(DateTime: TDateTime):String; DateTimeToString 將時間格式轉為字串。 procedure DateTimeToString(var Result: string;const Format: string;DateTime: TDateTime); DateToStr 將日期格式轉為字串。function DateToStr(Date: TDateTime): String; DayOfWeek 傳回今天星期幾。function DayOfWeek(Date: TDateTime): Integer; DecodeDate 分解所指定的日期為年、月、日。 procedure DecodeDate(Date: TDateTime;var Year, Month, Day:Word); DecodeTime 分解所指定的日期為時、分、秒。 procedure DecodeTime(Time: TDateTime;var Hour, Min, Sec,MSec: Word); EncodeDate 傳回將年、月、日所組合的日期格式。 function EncodeDate(Year, Month, Day: Word):TDateTime; EncodeTime 傳回將時、分、秒所組合的時間格式。 function EncodeTime(Hour, Min, Sec, MSec:Word): TDateTime; FormatDateTime 以指定的格式傳回日期時間。 function FormatDateTime(const Format: string;DateTime: TDateTime):String; Now 傳回現在的日期時間。function Now: TDateTime; StrToDate 將字串轉為日期格式。function StrToDate(const S:string): TDateTime; StrToDateTime 將字串轉為日期時間格式 function StrToDateTime(const S: string): TDateTime; StrToTime 將字串轉為時間格式。function StrToTime(const S:string): TDateTime; Time 傳回現在時間。function Time: TDateTime; TimeToStr 將時格式轉為字串。function TimeToStr(Time:TDateTime): String; ======================================== 動態配置函數(Dynamic Allocation Routines) Unit: System ======================================== Dispose 釋回一個動態變數。procedure Dispose(var P: Pointer); Free 釋放一個物件複本。procedure Free; FreeMem 釋回一給定大小的動態變數。 procedure FreeMem(var P:Pointer; Size: Word); GetMem 建立一個指定大小的動態變數,並由Pointer 參數傳回位址。 procedure GetMem(var P:Pointer; Size: Word); New 建立一個新的動態變數,並將Pointer 參數指向它。 procedure New(var P: Pointer); function New():Pointer; MaxAvail 傳回連續最大的可配置空間。function MaxAvail: Longint; MemAvail 傳回所有的可配置空間。function MemAvail: Longint; ======================================== 檔案管理函數 Unit: SysUtils ======================================== ChangeFileExt 變更檔案的延伸檔名。 function ChangeFileExt(const FileName,Extension: string):string; DateTimeToFileDate 將Delphi 的日期格式轉換為DOS的日期格式。 functionDateTimeToFileDate(DateTime:TDateTime): Longint; DeleteFile 刪除一個檔案。 function DeleteFile(const FileName: string):Boolean; DiskFree 傳回磁碟的可用空間。function DiskFree(Drive: Byte): Longint; DiskSize 傳回指定磁碟的容量大小。function DiskSize(Drive: Byte): Longint; ExpandFileName 傳回一個完整的路徑及檔名字串。 function expandFileName(const FileName: string):string; ExtractFileExt 傳回檔案的延伸檔名。 function ExtractFileExt(const FileName string):string; ExtractFileName 傳回檔案的檔名。 function ExtractFileName(const FileName: string):string; ExtractFilePath 傳回檔案的路徑。 function ExtractFilePath(const FileName: string):string; FileAge 傳回檔案的年紀function FileAge(const FileName: string):Longint; FileCreate 以指定檔名建立一個檔案。 function FileCreate(const FileName: string):Integer; FileClose 關閉指定的檔案。procedureFileClose(Handle: Integer); FileDateToDateTime 將DOS 的日期格式轉為Delphi 的日期格式。 function FileDateToDateTime(FileDate: Longint):TDateTime; FileExists 判別檔案是否存在。function FileExists(const FileName: string):Boolean; FileGetAttr 傳回檔案屬性。function FileGetAttr(const FileName: string):Integer; FileGetDate 傳回檔案的日期及時間。function FileGetDate(Handle: Integer): Longint; FileRead 從指定的檔案讀入資料。 function FileRead(Handle:Integer; var Buffer;Count:Longint):Longint; FileSearch 在目錄列中搜尋指定的檔案。 function FileSearch(constName, DirList: string):string; FileSeek 改變檔案游標的位置。 function FileSeek(Handle: Integer;Offset: Longint;Origin: Integer):Longint; FileSetAttr 設定檔案屬性。 function FileSetAttr(const FileName: string;Attr:Integer): Integer; FileSetDate 設定檔案的日期及時間。 procedure FileSetDate(Handle: Integer; Age:Longint); FileOpen 開啟檔案。 function FileOpen(const FileName: string; Mode:Word): Integer; FileWrite 寫資料到檔案。 function FileWrite(Handle:Integer;const Buffer; Count:Longint): Longint; FindClose 終止找尋第一個/下一個的動作。 procedure FindClose(var SearchRec: TSearchRec); FindFirst 尋找第一個符合的檔案並設定其屬性。 function FindFirst(const Path: string;Attr: Word; var F:TSearchRec): Integer; FindNext 傳回下一個符合的檔案。function FindNext(var F:TSearchRec): Integer; RenameFile 變更檔名。function RenameFile(const OldName,NewName: string):Boolean; ======================================== 浮點數轉換函數 (Floating-point Conversion Routines) Unit: SysUtils ======================================== FloatToDecimal 將浮點數值分成小數及整數部份的數字傳回。 procedure FloatToDecimal(var Result: TFloatRec;Value:Extended;Precision, Decimals:Integer); FloatToStrF 依照指定格式將浮點數轉成字串描述。 function FloatToStrF(Value: Extended; Format:TFloatFormat;Precision,Digits: Integer): string; FloatToStr 將浮點數轉成字串描述。function FloatToStr(Value: Extended): string; FloatToText 將所給的浮點數值,分成小數及整數部份的數字依照格式傳回。 function FloatToText(Buffer: Pchar; Value:Extended;Format:TFloatFormat;Precision,Digits: Integer): Integer; FloatToTextFmt 將浮點數依照格式轉成字串傳回。 function FloatToTextFmt(Buffer: PChar; Value:Extended;Format: PChar) :Integer; FormatFloat 將浮點數值依照Format 格式傳回。 function FormatFloat(constFormat: string;Value:Extended):string; StrToFloat 將所給字串轉成一個浮點數值。 function StrToFloat(const S: string): Extended; TextToFloat 將一個null 結尾字串轉成浮點數值 function TextToFloat(Buffer: PChar;var Value:Extended): Boolean; ======================================== 流程控制函數 (Flow-control Routines) Unit: System ======================================== Break 終止迴圈。如for, while 及repeat 迴圈。 procedure Break; Continue 繼續迴圈。如for, while 及repeat 迴圈。 procedure Continue; Exit 離開目前的區塊。procedure Exit; Halt 停止程式的執行並回到作業系統。 procedure Halt[ ( Exitcode: Word ) ]; RunError 停止程式執行。procedure RunError[ ( Errorcode: Byte ) ]; ======================================== 輸出入函數 (I/O Routines) Unit: System ======================================== AssignFile 指定一個檔案到檔案變數。procedure AssignFile(var f, String); CloseFile 關閉檔案。procedure CloseFile(var F); Eof 判斷是否已到檔案結尾。 Typed or untyped files: functionEof(var F): BooleanText files:function Eof [ (var F: Text) ]:Boolean; Erase 清除檔案內容。procedure Erase(var F); FilePos 傳回目前檔案游標位置。function FilePos(var F): Longint; FileSize 傳回檔案的大小function FileSize(var F):Longint; GetDir 傳回指定磁碟的工作目錄。procedure GetDir(D: Byte; var S: String); IOResult 傳回最後I/O 執行的狀態。function IOResult: Integer; MkDir 建立一子目錄。procedure MkDir(S: String); Rename 變更外部檔案的檔名。procedure Rename(var F; Newname); Reset 開啟一個已存在的檔案。procedure Reset(var F [: File; Recsize: Word ] ); Rewrite 建立並開啟一個新檔。procedure Rewrite(var F: File [; Recsize: Word ] ); RmDir 刪除一個空目錄。procedure RmDir(S: String); Seek 移動檔案游標。procedure Seek(var F; N: Longint); Truncate 刪截目前位置以後的檔案內容。procedure Truncate(var F); ======================================== 記憶體管理函數 Memory-management Routines) Unit: SysUtils ======================================== AllocMem 配置一個記憶體區塊給堆積heap 。 function AllocMem(Size: Cardinal): Pointer; ReAllocMem 從堆積釋回一區塊。 function ReAllocMem(P: Pointer;CurSize, NewSize:Cardinal): Pointer; ======================================== 雜項函數 (Miscellaneous Routines) Unit: System, SysUtils ======================================== AddExitProc 加入一個程序到執行時期程式庫的出口程序列中。 procedure AddExitProc(Proc: TProcedure); Exclude 從一個集合除去一個元素。procedure Exclude(var S: set of T;I:T); FillChar 以一個字元填入指定個數到一個變數上。 procedure FillChar(var X; Count: Word; value); Hi 傳回參數的高位元組。function Hi(X): Byte; Include 將元素包含到集合內。procedure Include(var S: set of T; I:T); Lo 傳回參數的低位元組。function Lo(X): Byte; Move 從Source 複製Count 個數的位元組到Dest 。 procedure Move(varSource,Dest; Count: Word); ParamCount 傳回命令列參數的個數。function ParamCount: Word; ParamStr 傳回一個指定的命令列參數。function ParamStr(Index): String; Random 傳回一個隨機亂數。function Random[ ( Range: Word) ]; Randomize 初值化亂數產生器。procedure Randomize; SizeOf 傳回參數所佔位元組數。function SizeOf(X): Word; Swap 將參數的高位元組和低位元組交換。function Swap(X); TypeOf 傳回指向物件型態的虛擬方法表的指標。function TypeOf(X) : Pointer UpCase 將字元轉為大寫。function UpCase(Ch: Char):Char; ======================================== 次序函數 (Ordinal Routines) Unit: System ======================================== Dec 遞減一個變數。procedure Dec(var X[ ; N:Longint]); Inc 遞增一個變數procedure Inc(var X[ ; N:Longint ] ); Odd 判別式否為奇數。function Odd(X: Longint):Boolean; Pred 傳回參數的前任者。function Pred(X); Succ 傳回參數的後繼者。function Succ(X); ======================================== 指標和位址函數 (Pointer and Address Routines) Unit: System ======================================== addr 傳回指定物件的位址。function Addr(X): pointer; Assigned 判斷是否一個函數或程序是nil function Assigned(var P):Boolean; CSeg 傳回CS 程式段暫存器的內容。function CSeg: Word; DSeg 傳回DS 資料段暫存器的內容。function DSegt: Word; Ofs 傳回參數的偏移位址。function Ofs(X): Word; Ptr 將所指定的節段及偏移位址組合到一個指標。function Ptr(Seg, Ofs: Word):Pointer; Seg 傳回參數的節段位址。function Seg(X): Word; SPtr 傳回SP 堆疊存器的內容。function SPtr: Word; SSeg 傳回SS 堆疊段暫存器的內容。function SSeg: Word; ======================================== 字串格式函數 (String-formatting Routines) Unit: SysUtils ======================================== FmtStr 將所列參數依照Format 的格式組合到Result 字串傳回。 procedure FmtStr(var Resut: string; const Format:string;const Args: array of const); Format 將所列參數依照Format 的格式組合到Pascal 格式字串傳回。 fonction Format(const Format: string;const Args:array of const): string; FormatBuf 格式化所列的參數。 function FormatBuf(var Buffer; BufLen: Word;const Format; FmtLen:Word;Const Args: array of const):Word; StrFmt 格式化所列的參數。function StrFmt(Buffer, Format: PChar;const Args: array of const):PChar; StrLFmt 格式化所列參數,並將結果指向Buffer 指標。 function StrLFmt(Buffer: PChar; MxLen: Word;Format: PChar;const Args: array of const):PChar; ======================================== 字串處理函數(String-handling Routines :Pascal-style) Unit: SystUtils ======================================== AnsiCompareStr 比較兩個字串。function AnsiCompareStr(const S1, S2: string):Integer; AnsiCompareText 比較兩個字串且無大小寫區別。 function AnsiCompareText(const S1, S2: string):Integer; AnsiLowerCase 將字串內容轉為小寫。function AnsiLowerCase(const S: string): string; AnsiUpperCase 將字串內容轉為大寫。function AnsiUpperCase(const S: string): string; AppendStr 將所給字串連接到Dest 字串後面。 procedure AppendStr(var Dest: string; const S:string); AssignStr 配置記憶體空間給字串。 procedure AppendStr(var P: PString; const S:String); CompareStr 比較兩個字串。 function CompareStr(const S1,S2: string):Integer; CompareText 比較兩個字串且無大小寫區別。 function CompareText(const S1, S2: String):Integer; Concat 連結所列字串。function Concat(s1 [, s2,… , sn]: String):String; Copy 傳回字串的部份字串內容。function Copy(S: String; Index, Count:Integer): String; Delete 刪除所給字串內的子字串。procedure Delete(var S: String; Index,Count:Integer); DisposeStr 釋回字串佔用的空間。procedure DisposeStr(P: PString); FmtLoadStr 從程式的資源字串表中載入一個字串。 function FmtLoadStr(Ident: Word;const Args: array of const): string; Insert 在一個字串內插入一個子字串 procedure Insert(Source: String; var S: String;Index: Integer); IntToHex 將一個整數轉為十六進位。 function IntToHex(Value: Longint; Digits:Integer): string; IntToStr 將數字轉成字中格式。function IntToStr(Value: Longint): string; IsValidIdent 判別字串內容是否為正確的識別字。 function IsValidIdent(const Ident: string):Boolean; Length 傳回字串的長度。function Length(S: String): Integer; LoadStr 從應用程式的可執行檔中載入一個字串資源。 function LoadStr(Ident: Word): string; LowerCase 將字串轉成小寫。function LowerCase(const S: string): string; NewStr 從堆積配置一個字串空間。function NewStr(const S: string): PString; Pos 傳回子字串在字串中的位置。function Pos(Substr: String; S: String): Str 將數值轉為字串。procedure Str(X [: Width [: Decimals ]];var S); StrToInt 將字串轉為整數值。function StrToInt(const S: string): Longint; StrToIntDef 將字串轉整數值或預設值。 function StrToIntDef(const S: string; Default:Longint): Longint; Uppercase 將字串轉成大寫。function UpperCase(const S: string): string; val 將字串內容轉為數值描述。procedureVal(S; var V; var Code: Integer); ======================================== 字串處理函數 (String-handling Routines : Null-terminated) Unit: SysUtils ======================================== StrAlloc 配置一個最大長度為Size-1 的緩衝區給null 結尾字串 function StrAlloc(Size: Word): PChar; StrBufSize 傳回由StrAlloc 配置的字串緩衝區內可以儲存的最大字元數。 function StrBufSize(Str: PChar): Wrd;StrCat 連結兩個字串並傳回該字串。 function StrCat(Dest, Source: PCar): PChar; StrComp 比照兩個字串。function StrComp(Str1, Str2 : Pchar): Integer; StrCopy 拷貝Source 字串到Dest 上。function StrCopy(Dest, Source: PChar): PChar StrDispose 釋回一個字串空間。function StrDispose(Str:PChar); StrCopy 拷貝Source 字串到Dest 上並傳回指向該字串結尾的指標。 function StrECopy(Dest, Surce: Pchar): Pchar; StrEnd 傳回一指標指向字串的結尾function StrEnd(Str: Pchar): Pchar; StrLCat 將Source 字串連結到Dest 字串後,並傳回連結的字串。 function StrLCat(Dest, Source:PCar; MaxLen: Word): PChar; StrIComp 比較兩個字串具無大小寫區別 function StrIComp(Str1, Str2:Pchar): Integer; StrLComp 比較兩個字串到所指定的最大長度 function StrLComp(Str1, Str2:Pchar; MaxLen: Word): Integer; StrLCopy 從一字串拷貝指定字元數到另一字串 Function StrLCopy(Dest,Source:PChar;MaxLen: Cardinal): PChar; StrLen 傳回字串的長度。function StrLen(Str: PChar):Cardinal; StrLIComp 比較兩個字串到所指定的最大長度具無大小寫區別。 function StrLIComp(Str1, Str2:PChar; MaxLen: Word):Integer; StrLower 將字串轉成小寫。 function StrLower(Str: PChar):PChar; StrMove 拷貝Count 字元數,從Source 到Dest字串。 function StrMove(Dest, Source:PChar; Count: Cardinal): PChar StrNew 從堆積配置一個字串。function StrNew(Str: PChar):PChar; StrPas 將null 結尾字中轉成一個Pascal 格式字串。 function StrPas(Str: Pchar):String; StrPCopy 拷貝一個Pascal 格式字串到一個null結尾字串。 Function StrPCopy(Dest:PChar;Source: String): PChar; StrPLCopy 拷貝MaxLen 所指字元數,從Pascal格式字串到null 結尾字串。 Function StrPLCopy(Dest:Pchar;cost Source: string;MaxLen: Word): PChar; StrPos 傳回一指標指向在Str1 內最先出現 Str2 字串的位置。 function StrPos(Str1, Str2: Pchar): Pchar; StrScan 傳回一指標指向在Str 字串中第一個出現chr 字元的位置。 function StrScan(Str: PChar; Chr: Char): PChar; StrRScan 傳回一指標指向在Str 子串中最後出現chr 字元的位置。 function StrRScan(Str: Pchar; Chr: Char): PChar; StrUpper 將字串轉成大寫。function StrUpper(Str: PChar):PChar; ======================================== 文字檔案函數 (Text-file Routines) Unit: System ======================================== Append 開啟一個存在的檔案供增加。procedure Append(var f: Text); Eoln 判別一文字檔是否在行尾。function Eoln [(var F: Text) ]:Boolean; Flush 清除文字輸出檔的緩衝區。procedure Flush(var F: Text); Read 從檔案讀入資料到所列變數。Typed files: Procedure Read(F , V1[, V2,… ,Vn ] );Text files: procedure Read( [ var F: Text; ] V1 [,V2,… ,Vn]); Readln 從檔案讀入資料到所列變數並跳至下一行。 procedure Readln( [ var F:Text; ]V1 [, V2,… ,Vn ]); SeekEof 判別是否已到檔尾。function SeekEof [ ( var F:Text) ]: Boolean; SeekEoln 判別一檔案是否在行尾。function SeekEoln [(var F: Text) ]: Boolean; SetTextBuf 指定一個I/O 緩衝區給一文字檔。 procedure SetTextBuf(var F: Text; var Buf [ ; Size:Word ] ); Write 將變數內的資料寫到檔案。Text files: procedure Write( [ var F:Text; ] P1 [,P2,… ,Pn ] ); Typed files: procedure Write(F, V1[V2,… Vn]); writeln 執行Write 程序並輸出一個跳行到檔案。 procedure Writeln([ var F: Text; ] P1 [, P2,… ,Pn ] ); ======================================== 轉換函數(Transfer Routines) Unit: System ======================================== Chr 傳回ASCII 碼所對應的字元。function Chr(X: Byte): Char; Delphi 源碼任務 ( http://home.kimo.com.tw/bruce0211/ ) 打字整理15 High 傳回參數在範圍內的最高值。function High(X); Low 傳回參數在範圍內的最低值。function Low(X); Ord 傳回一個有序型態所對應的順序值。function Ord(X): Longint; Round 將一個實數值四捨五入而傳回整數值。function Round(X: Real):Longint; Trunc 將一個實數值去尾而傳回整數值。function Trunc(X: Real):Longint; ======================================== 未定型態檔案函數(Untyped-file Routines) Unit: System ======================================== BlockRead 從檔案讀入一個或數個記錄到Buf 變數。 procedure BlockRead(var F: File; var Buf;Count: Word [; var Result:Word]); BlockWrite 從一變數寫入一個或數個記錄。 procedure BlockWrite(var f: File; var Buf;Count: Word [; var Result:Word]); ▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼ 發表人 - banson1716 於 2003/05/15 13:40:20
solnone
中階會員


發表:2
回覆:97
積分:69
註冊:2003-05-06

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-05-16 03:13:38 IP:203.66.xxx.xxx 未訂閱
請問一下,WinCrt應該不是delphi原本就有的吧,可以在那找到它呢? 謝謝!
banson1716
高階會員


發表:55
回覆:182
積分:167
註冊:2002-04-14

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-05-16 18:44:24 IP:218.175.xxx.xxx 未訂閱
Delphi 2.0並沒有 WinCrt單元。 這是因為我們可以用其它方法來取代它。在 Project|Options 的 Linker 頁次中將『Generate console application』選項打開,你就可以像以前使用 WinCrt 單元一樣地寫程序了!    
引言: 請問一下,WinCrt應該不是delphi原本就有的吧,可以在那找到它呢? 謝謝!
boon
一般會員


發表:0
回覆:1
積分:0
註冊:2003-04-26

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-05-18 03:14:22 IP:61.10.xxx.xxx 未訂閱
thank u    
引言: Delphi Function 中文說明函式及簡要範例 ▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼ ====================================================================== 數學函數 (Arithmetic Routines) Unit: System ====================================================================== Abs 傳回參數的絕對值。 function Abs(X); ArcTan 傳回正切函數的反函數值。 function ArcTan(X: Real): Real; Cos 傳回餘弦函數值 function Cos(X: Real): Real; (X 以弧度為單位)。 Exp 傳回自然指數值。 function Cos(X: Real): Real; Frac 傳回參數的小數部份。 function Frac(X: Real): Real; Int 傳回參數的整數部份。 function Int(X: Real): Real; Ln 傳回自然對數值。 function Ln(X: Real): Real; Pi 傳回圓周率π的值。 function Pi: Real; Sin 傳回正弦函數值。 function Sin(X: Real): Real; Sqr 傳回參數的平方。 function Sqr(X: Real): (Real); Sqrt 傳回參數的平方根。 function Sqrt(X: Real): Real; =========================================================================== 控制台函數 (Console Routines) =========================================================================== Unit: WinCrt 函數名稱 函數說明 函數語法 =========================================================================== AssignCrt 將文字檔連結到一個控制台視窗。 procedure AssignCrt(var f: Text); ClrEol 清附游標位置到該行最後的所有字元。procedure ClrEol; ClrScr 清附螢幕並重置游標至左上角。 procedure ClrScr; CursorTo 移動游標至給定座標。 procedure CursorTo(X, Y:Integer); DoneWinCrt 結束控制台視窗。 procedure DoneWinCrt; GotoXY 移動游標至給定座標。 procedure GotoXY(X, Y: Byte); InitWinCrt 建立控制台視窗。 procedure InitWinCrt; KeyPressed 判斷是否有一按鍵。 function KeyPressed:Boolean; ReadBuf 從控制台視窗讀入一行。 function ReadBuf(Buffer: Pchar;Count: Word): ReadKey 讀取按鍵字元。 function ReadKey: Char; ScrollTo 捲動控制台視窗至顯示位置。 procedure ScrollTo(X, Y: Integer); TrackCursor 捲動控制台視窗宜到游標可見。procedure TrackCursor; WhereX 傳回游標的X 座標。 function WhereX: Byte; WhereY 傳回游標的Y 標標。 function WhereY: Byte; WriteBuf 寫入一區塊字元到控制台視窗。 procedure WriteBuf WriteChar 寫一個字元到控制台視窗。 procedure WriteChar(CH: Char); ================================================= 日期與時間函數 (Date and Time Routines) Unit: SysUtils ======================================== Date 傳回今天日期。function Date: TDateTime; DateTimeToStr 將時間格式轉為字串。function DateTimeToStr(DateTime: TDateTime):String; DateTimeToString 將時間格式轉為字串。 procedure DateTimeToString(var Result: string;const Format: string;DateTime: TDateTime); DateToStr 將日期格式轉為字串。function DateToStr(Date: TDateTime): String; DayOfWeek 傳回今天星期幾。function DayOfWeek(Date: TDateTime): Integer; DecodeDate 分解所指定的日期為年、月、日。 procedure DecodeDate(Date: TDateTime;var Year, Month, Day:Word); DecodeTime 分解所指定的日期為時、分、秒。 procedure DecodeTime(Time: TDateTime;var Hour, Min, Sec,MSec: Word); EncodeDate 傳回將年、月、日所組合的日期格式。 function EncodeDate(Year, Month, Day: Word):TDateTime; EncodeTime 傳回將時、分、秒所組合的時間格式。 function EncodeTime(Hour, Min, Sec, MSec:Word): TDateTime; FormatDateTime 以指定的格式傳回日期時間。 function FormatDateTime(const Format: string;DateTime: TDateTime):String; Now 傳回現在的日期時間。function Now: TDateTime; StrToDate 將字串轉為日期格式。function StrToDate(const S:string): TDateTime; StrToDateTime 將字串轉為日期時間格式 function StrToDateTime(const S: string): TDateTime; StrToTime 將字串轉為時間格式。function StrToTime(const S:string): TDateTime; Time 傳回現在時間。function Time: TDateTime; TimeToStr 將時格式轉為字串。function TimeToStr(Time:TDateTime): String; ======================================== 動態配置函數(Dynamic Allocation Routines) Unit: System ======================================== Dispose 釋回一個動態變數。procedure Dispose(var P: Pointer); Free 釋放一個物件複本。procedure Free; FreeMem 釋回一給定大小的動態變數。 procedure FreeMem(var P:Pointer; Size: Word); GetMem 建立一個指定大小的動態變數,並由Pointer 參數傳回位址。 procedure GetMem(var P:Pointer; Size: Word); New 建立一個新的動態變數,並將Pointer 參數指向它。 procedure New(var P: Pointer); function New():Pointer; MaxAvail 傳回連續最大的可配置空間。function MaxAvail: Longint; MemAvail 傳回所有的可配置空間。function MemAvail: Longint; ======================================== 檔案管理函數 Unit: SysUtils ======================================== ChangeFileExt 變更檔案的延伸檔名。 function ChangeFileExt(const FileName,Extension: string):string; DateTimeToFileDate 將Delphi 的日期格式轉換為DOS的日期格式。 functionDateTimeToFileDate(DateTime:TDateTime): Longint; DeleteFile 刪除一個檔案。 function DeleteFile(const FileName: string):Boolean; DiskFree 傳回磁碟的可用空間。function DiskFree(Drive: Byte): Longint; DiskSize 傳回指定磁碟的容量大小。function DiskSize(Drive: Byte): Longint; ExpandFileName 傳回一個完整的路徑及檔名字串。 function expandFileName(const FileName: string):string; ExtractFileExt 傳回檔案的延伸檔名。 function ExtractFileExt(const FileName string):string; ExtractFileName 傳回檔案的檔名。 function ExtractFileName(const FileName: string):string; ExtractFilePath 傳回檔案的路徑。 function ExtractFilePath(const FileName: string):string; FileAge 傳回檔案的年紀function FileAge(const FileName: string):Longint; FileCreate 以指定檔名建立一個檔案。 function FileCreate(const FileName: string):Integer; FileClose 關閉指定的檔案。procedureFileClose(Handle: Integer); FileDateToDateTime 將DOS 的日期格式轉為Delphi 的日期格式。 function FileDateToDateTime(FileDate: Longint):TDateTime; FileExists 判別檔案是否存在。function FileExists(const FileName: string):Boolean; FileGetAttr 傳回檔案屬性。function FileGetAttr(const FileName: string):Integer; FileGetDate 傳回檔案的日期及時間。function FileGetDate(Handle: Integer): Longint; FileRead 從指定的檔案讀入資料。 function FileRead(Handle:Integer; var Buffer;Count:Longint):Longint; FileSearch 在目錄列中搜尋指定的檔案。 function FileSearch(constName, DirList: string):string; FileSeek 改變檔案游標的位置。 function FileSeek(Handle: Integer;Offset: Longint;Origin: Integer):Longint; FileSetAttr 設定檔案屬性。 function FileSetAttr(const FileName: string;Attr:Integer): Integer; FileSetDate 設定檔案的日期及時間。 procedure FileSetDate(Handle: Integer; Age:Longint); FileOpen 開啟檔案。 function FileOpen(const FileName: string; Mode:Word): Integer; FileWrite 寫資料到檔案。 function FileWrite(Handle:Integer;const Buffer; Count:Longint): Longint; FindClose 終止找尋第一個/下一個的動作。 procedure FindClose(var SearchRec: TSearchRec); FindFirst 尋找第一個符合的檔案並設定其屬性。 function FindFirst(const Path: string;Attr: Word; var F:TSearchRec): Integer; FindNext 傳回下一個符合的檔案。function FindNext(var F:TSearchRec): Integer; RenameFile 變更檔名。function RenameFile(const OldName,NewName: string):Boolean; ======================================== 浮點數轉換函數 (Floating-point Conversion Routines) Unit: SysUtils ======================================== FloatToDecimal 將浮點數值分成小數及整數部份的數字傳回。 procedure FloatToDecimal(var Result: TFloatRec;Value:Extended;Precision, Decimals:Integer); FloatToStrF 依照指定格式將浮點數轉成字串描述。 function FloatToStrF(Value: Extended; Format:TFloatFormat;Precision,Digits: Integer): string; FloatToStr 將浮點數轉成字串描述。function FloatToStr(Value: Extended): string; FloatToText 將所給的浮點數值,分成小數及整數部份的數字依照格式傳回。 function FloatToText(Buffer: Pchar; Value:Extended;Format:TFloatFormat;Precision,Digits: Integer): Integer; FloatToTextFmt 將浮點數依照格式轉成字串傳回。 function FloatToTextFmt(Buffer: PChar; Value:Extended;Format: PChar) :Integer; FormatFloat 將浮點數值依照Format 格式傳回。 function FormatFloat(constFormat: string;Value:Extended):string; StrToFloat 將所給字串轉成一個浮點數值。 function StrToFloat(const S: string): Extended; TextToFloat 將一個null 結尾字串轉成浮點數值 function TextToFloat(Buffer: PChar;var Value:Extended): Boolean; ======================================== 流程控制函數 (Flow-control Routines) Unit: System ======================================== Break 終止迴圈。如for, while 及repeat 迴圈。 procedure Break; Continue 繼續迴圈。如for, while 及repeat 迴圈。 procedure Continue; Exit 離開目前的區塊。procedure Exit; Halt 停止程式的執行並回到作業系統。 procedure Halt[ ( Exitcode: Word ) ]; RunError 停止程式執行。procedure RunError[ ( Errorcode: Byte ) ]; ======================================== 輸出入函數 (I/O Routines) Unit: System ======================================== AssignFile 指定一個檔案到檔案變數。procedure AssignFile(var f, String); CloseFile 關閉檔案。procedure CloseFile(var F); Eof 判斷是否已到檔案結尾。 Typed or untyped files: functionEof(var F): BooleanText files:function Eof [ (var F: Text) ]:Boolean; Erase 清除檔案內容。procedure Erase(var F); FilePos 傳回目前檔案游標位置。function FilePos(var F): Longint; FileSize 傳回檔案的大小function FileSize(var F):Longint; GetDir 傳回指定磁碟的工作目錄。procedure GetDir(D: Byte; var S: String); IOResult 傳回最後I/O 執行的狀態。function IOResult: Integer; MkDir 建立一子目錄。procedure MkDir(S: String); Rename 變更外部檔案的檔名。procedure Rename(var F; Newname); Reset 開啟一個已存在的檔案。procedure Reset(var F [: File; Recsize: Word ] ); Rewrite 建立並開啟一個新檔。procedure Rewrite(var F: File [; Recsize: Word ] ); RmDir 刪除一個空目錄。procedure RmDir(S: String); Seek 移動檔案游標。procedure Seek(var F; N: Longint); Truncate 刪截目前位置以後的檔案內容。procedure Truncate(var F); ======================================== 記憶體管理函數 Memory-management Routines) Unit: SysUtils ======================================== AllocMem 配置一個記憶體區塊給堆積heap 。 function AllocMem(Size: Cardinal): Pointer; ReAllocMem 從堆積釋回一區塊。 function ReAllocMem(P: Pointer;CurSize, NewSize:Cardinal): Pointer; ======================================== 雜項函數 (Miscellaneous Routines) Unit: System, SysUtils ======================================== AddExitProc 加入一個程序到執行時期程式庫的出口程序列中。 procedure AddExitProc(Proc: TProcedure); Exclude 從一個集合除去一個元素。procedure Exclude(var S: set of T;I:T); FillChar 以一個字元填入指定個數到一個變數上。 procedure FillChar(var X; Count: Word; value); Hi 傳回參數的高位元組。function Hi(X): Byte; Include 將元素包含到集合內。procedure Include(var S: set of T; I:T); Lo 傳回參數的低位元組。function Lo(X): Byte; Move 從Source 複製Count 個數的位元組到Dest 。 procedure Move(varSource,Dest; Count: Word); ParamCount 傳回命令列參數的個數。function ParamCount: Word; ParamStr 傳回一個指定的命令列參數。function ParamStr(Index): String; Random 傳回一個隨機亂數。function Random[ ( Range: Word) ]; Randomize 初值化亂數產生器。procedure Randomize; SizeOf 傳回參數所佔位元組數。function SizeOf(X): Word; Swap 將參數的高位元組和低位元組交換。function Swap(X); TypeOf 傳回指向物件型態的虛擬方法表的指標。function TypeOf(X) : Pointer UpCase 將字元轉為大寫。function UpCase(Ch: Char):Char; ======================================== 次序函數 (Ordinal Routines) Unit: System ======================================== Dec 遞減一個變數。procedure Dec(var X[ ; N:Longint]); Inc 遞增一個變數procedure Inc(var X[ ; N:Longint ] ); Odd 判別式否為奇數。function Odd(X: Longint):Boolean; Pred 傳回參數的前任者。function Pred(X); Succ 傳回參數的後繼者。function Succ(X); ======================================== 指標和位址函數 (Pointer and Address Routines) Unit: System ======================================== addr 傳回指定物件的位址。function Addr(X): pointer; Assigned 判斷是否一個函數或程序是nil function Assigned(var P):Boolean; CSeg 傳回CS 程式段暫存器的內容。function CSeg: Word; DSeg 傳回DS 資料段暫存器的內容。function DSegt: Word; Ofs 傳回參數的偏移位址。function Ofs(X): Word; Ptr 將所指定的節段及偏移位址組合到一個指標。function Ptr(Seg, Ofs: Word):Pointer; Seg 傳回參數的節段位址。function Seg(X): Word; SPtr 傳回SP 堆疊存器的內容。function SPtr: Word; SSeg 傳回SS 堆疊段暫存器的內容。function SSeg: Word; ======================================== 字串格式函數 (String-formatting Routines) Unit: SysUtils ======================================== FmtStr 將所列參數依照Format 的格式組合到Result 字串傳回。 procedure FmtStr(var Resut: string; const Format:string;const Args: array of const); Format 將所列參數依照Format 的格式組合到Pascal 格式字串傳回。 fonction Format(const Format: string;const Args:array of const): string; FormatBuf 格式化所列的參數。 function FormatBuf(var Buffer; BufLen: Word;const Format; FmtLen:Word;Const Args: array of const):Word; StrFmt 格式化所列的參數。function StrFmt(Buffer, Format: PChar;const Args: array of const):PChar; StrLFmt 格式化所列參數,並將結果指向Buffer 指標。 function StrLFmt(Buffer: PChar; MxLen: Word;Format: PChar;const Args: array of const):PChar; ======================================== 字串處理函數(String-handling Routines :Pascal-style) Unit: SystUtils ======================================== AnsiCompareStr 比較兩個字串。function AnsiCompareStr(const S1, S2: string):Integer; AnsiCompareText 比較兩個字串且無大小寫區別。 function AnsiCompareText(const S1, S2: string):Integer; AnsiLowerCase 將字串內容轉為小寫。function AnsiLowerCase(const S: string): string; AnsiUpperCase 將字串內容轉為大寫。function AnsiUpperCase(const S: string): string; AppendStr 將所給字串連接到Dest 字串後面。 procedure AppendStr(var Dest: string; const S:string); AssignStr 配置記憶體空間給字串。 procedure AppendStr(var P: PString; const S:String); CompareStr 比較兩個字串。 function CompareStr(const S1,S2: string):Integer; CompareText 比較兩個字串且無大小寫區別。 function CompareText(const S1, S2: String):Integer; Concat 連結所列字串。function Concat(s1 [, s2,… , sn]: String):String; Copy 傳回字串的部份字串內容。function Copy(S: String; Index, Count:Integer): String; Delete 刪除所給字串內的子字串。procedure Delete(var S: String; Index,Count:Integer); DisposeStr 釋回字串佔用的空間。procedure DisposeStr(P: PString); FmtLoadStr 從程式的資源字串表中載入一個字串。 function FmtLoadStr(Ident: Word;const Args: array of const): string; Insert 在一個字串內插入一個子字串 procedure Insert(Source: String; var S: String;Index: Integer); IntToHex 將一個整數轉為十六進位。 function IntToHex(Value: Longint; Digits:Integer): string; IntToStr 將數字轉成字中格式。function IntToStr(Value: Longint): string; IsValidIdent 判別字串內容是否為正確的識別字。 function IsValidIdent(const Ident: string):Boolean; Length 傳回字串的長度。function Length(S: String): Integer; LoadStr 從應用程式的可執行檔中載入一個字串資源。 function LoadStr(Ident: Word): string; LowerCase 將字串轉成小寫。function LowerCase(const S: string): string; NewStr 從堆積配置一個字串空間。function NewStr(const S: string): PString; Pos 傳回子字串在字串中的位置。function Pos(Substr: String; S: String): Str 將數值轉為字串。procedure Str(X [: Width [: Decimals ]];var S); StrToInt 將字串轉為整數值。function StrToInt(const S: string): Longint; StrToIntDef 將字串轉整數值或預設值。 function StrToIntDef(const S: string; Default:Longint): Longint; Uppercase 將字串轉成大寫。function UpperCase(const S: string): string; val 將字串內容轉為數值描述。procedureVal(S; var V; var Code: Integer); ======================================== 字串處理函數 (String-handling Routines : Null-terminated) Unit: SysUtils ======================================== StrAlloc 配置一個最大長度為Size-1 的緩衝區給null 結尾字串 function StrAlloc(Size: Word): PChar; StrBufSize 傳回由StrAlloc 配置的字串緩衝區內可以儲存的最大字元數。 function StrBufSize(Str: PChar): Wrd;StrCat 連結兩個字串並傳回該字串。 function StrCat(Dest, Source: PCar): PChar; StrComp 比照兩個字串。function StrComp(Str1, Str2 : Pchar): Integer; StrCopy 拷貝Source 字串到Dest 上。function StrCopy(Dest, Source: PChar): PChar StrDispose 釋回一個字串空間。function StrDispose(Str:PChar); StrCopy 拷貝Source 字串到Dest 上並傳回指向該字串結尾的指標。 function StrECopy(Dest, Surce: Pchar): Pchar; StrEnd 傳回一指標指向字串的結尾function StrEnd(Str: Pchar): Pchar; StrLCat 將Source 字串連結到Dest 字串後,並傳回連結的字串。 function StrLCat(Dest, Source:PCar; MaxLen: Word): PChar; StrIComp 比較兩個字串具無大小寫區別 function StrIComp(Str1, Str2:Pchar): Integer; StrLComp 比較兩個字串到所指定的最大長度 function StrLComp(Str1, Str2:Pchar; MaxLen: Word): Integer; StrLCopy 從一字串拷貝指定字元數到另一字串 Function StrLCopy(Dest,Source:PChar;MaxLen: Cardinal): PChar; StrLen 傳回字串的長度。function StrLen(Str: PChar):Cardinal; StrLIComp 比較兩個字串到所指定的最大長度具無大小寫區別。 function StrLIComp(Str1, Str2:PChar; MaxLen: Word):Integer; StrLower 將字串轉成小寫。 function StrLower(Str: PChar):PChar; StrMove 拷貝Count 字元數,從Source 到Dest字串。 function StrMove(Dest, Source:PChar; Count: Cardinal): PChar StrNew 從堆積配置一個字串。function StrNew(Str: PChar):PChar; StrPas 將null 結尾字中轉成一個Pascal 格式字串。 function StrPas(Str: Pchar):String; StrPCopy 拷貝一個Pascal 格式字串到一個null結尾字串。 Function StrPCopy(Dest:PChar;Source: String): PChar; StrPLCopy 拷貝MaxLen 所指字元數,從Pascal格式字串到null 結尾字串。 Function StrPLCopy(Dest:Pchar;cost Source: string;MaxLen: Word): PChar; StrPos 傳回一指標指向在Str1 內最先出現 Str2 字串的位置。 function StrPos(Str1, Str2: Pchar): Pchar; StrScan 傳回一指標指向在Str 字串中第一個出現chr 字元的位置。 function StrScan(Str: PChar; Chr: Char): PChar; StrRScan 傳回一指標指向在Str 子串中最後出現chr 字元的位置。 function StrRScan(Str: Pchar; Chr: Char): PChar; StrUpper 將字串轉成大寫。function StrUpper(Str: PChar):PChar; ======================================== 文字檔案函數 (Text-file Routines) Unit: System ======================================== Append 開啟一個存在的檔案供增加。procedure Append(var f: Text); Eoln 判別一文字檔是否在行尾。function Eoln [(var F: Text) ]:Boolean; Flush 清除文字輸出檔的緩衝區。procedure Flush(var F: Text); Read 從檔案讀入資料到所列變數。Typed files: Procedure Read(F , V1[, V2,… ,Vn ] );Text files: procedure Read( [ var F: Text; ] V1 [,V2,… ,Vn]); Readln 從檔案讀入資料到所列變數並跳至下一行。 procedure Readln( [ var F:Text; ]V1 [, V2,… ,Vn ]); SeekEof 判別是否已到檔尾。function SeekEof [ ( var F:Text) ]: Boolean; SeekEoln 判別一檔案是否在行尾。function SeekEoln [(var F: Text) ]: Boolean; SetTextBuf 指定一個I/O 緩衝區給一文字檔。 procedure SetTextBuf(var F: Text; var Buf [ ; Size:Word ] ); Write 將變數內的資料寫到檔案。Text files: procedure Write( [ var F:Text; ] P1 [,P2,… ,Pn ] ); Typed files: procedure Write(F, V1[V2,… Vn]); writeln 執行Write 程序並輸出一個跳行到檔案。 procedure Writeln([ var F: Text; ] P1 [, P2,… ,Pn ] ); ======================================== 轉換函數(Transfer Routines) Unit: System ======================================== Chr 傳回ASCII 碼所對應的字元。function Chr(X: Byte): Char; Delphi 源碼任務 ( http://home.kimo.com.tw/bruce0211/ ) 打字整理15 High 傳回參數在範圍內的最高值。function High(X); Low 傳回參數在範圍內的最低值。function Low(X); Ord 傳回一個有序型態所對應的順序值。function Ord(X): Longint; Round 將一個實數值四捨五入而傳回整數值。function Round(X: Real):Longint; Trunc 將一個實數值去尾而傳回整數值。function Trunc(X: Real):Longint; ======================================== 未定型態檔案函數(Untyped-file Routines) Unit: System ======================================== BlockRead 從檔案讀入一個或數個記錄到Buf 變數。 procedure BlockRead(var F: File; var Buf;Count: Word [; var Result:Word]); BlockWrite 從一變數寫入一個或數個記錄。 procedure BlockWrite(var f: File; var Buf;Count: Word [; var Result:Word]); ▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼ 發表人 - banson1716 於 2003/05/15 13:40:20
系統時間:2024-04-27 5:19:33
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!