String processing functions
Unit System
Function prototype function Concat(s1 [, s2,..., sn]: string): string; Description is the same as S := S1 + S2 + S3 ...;. Add strings.
Function prototype function Copy(S: string; Index, Count: Integer): string; Description S: string. Indexd: starts copying from which bit. Count: How many digits to copy in total. Copy from the alpha string to another character string.
Function prototype PRocedure Delete(var S: string; Index, Count:Integer); Description S: string. Indexd: Delete from which bit. Count: How many digits should be deleted in total. Delete several characters in the string.
Function prototype procedure Insert(Source: string; var S: string; Index: Integer); Description Source: substring. S: string is inserted. Indexd: Insert from which bit. Insert a substring into another In string.
Function prototype function Length(S: string): Integer; Find the number of characters
Function prototype function Pos(Substr: string; S: string): Integer; Description Substr: substring.S: parent string. Find the position of the substring in the parent string.
Function prototype function LowerCase(const S: string): string; Convert all strings to lowercase letters.
Function prototype function UpperCase(const S: string): string; Convert all strings to capital letters.
pos(obj,target) Find the first character position of the first obj in the target string. If it cannot be found, return 0.
function StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string; function returns the replaced string description rfReplaceAll is the replacement all contents; rfIgnoreCase is the ignore case
function StringToGUID(const S: string): TGUID; function returns the string S to convert it into global identifier. If the string is illegal, an exception will be triggered.
function GUIDToString(const GUID: TGUID): string; function returns the global identity GUID to convert it into a string
Function prototype procedure Str(X [: Width [: Decimals ]]; var S); Converts a numeric value to a formatted string. Description X: Integer or real number to be converted. Width: Format length. (Integer) Decimals: Number of decimal places.(Integer)
Function prototype procedure Val(S; var V; var Code: Integer); Converts a string to a number. Explanation S: The string to be converted. V: The converted integer or the real number.Code: Code = 0 indicates that the conversion is successful.
Unit SysUtils
Function prototype function NewStr(const S: string): PString; Configure a new string space to the PString pointer in the heap.
Function prototype Procedure DisposeStr(P: PString); Release a string space PString pointer in heap.
Function prototype function IntToHex(Value: Integer; Digits: Integer): string;
Function prototype function IntToStr(Value: Integer): string;
Function prototype function StrToInt(const S: string): Integer;
Function prototype function StrToIntDef(const S: string; Default: Integer): Integer; Description Value: The integer to be converted. Digits: The Hex to be converted into several digits.
Function prototype function Trim(const S: string): string; Clears the blanks and control characters before and after the string.
Function prototype function TrimLeft(const S: string): string; Clears the blank and control characters on the left side of the string.
Function prototype function TrimRight(const S: string): string; Clears the blank and control characters on the right side of the string.
Function prototype function AdjustLineBreaks(const S: string): string; Change all newline symbols of strings to #13#10
Function prototype function StrAlloc(Size: Cardinal): PChar; Configure string space. Description Size=Maximum string space +1
Function prototype function StrBufSize(Str: PChar): Cardinal; Returns the size of the space configured by StrAlloc
Function prototype function StrCat(Dest, Source: PChar): PChar; add strings.
Function prototype function StrComp(Str1, Str2: PChar): Integer; Compare the size of two strings.
Function prototype function StrCopy(Dest, Source: PChar): PChar; Copy string.
Function prototype procedure StrDispose(Str: PChar); Free the space configured by StrAlloc or StrNew.
Function prototype function StrECopy(Dest, Source: PChar): PChar; Copy the string and pass it back to the end address of the string.
Function prototype function StrEnd(Str: PChar): PChar; Pass back the end address of the string.
Function prototype function StrIComp(Str1, Str2:PChar): Integer; Compare the size of two strings. (Case-independent)
Function prototype function StrLCat(Dest, Source: PChar; MaxLen: Cardinal): PChar; string addition. (Specify length)
Function prototype function StrLComp(Str1, Str2: PChar; MaxLen: Cardinal):Integer; Compare the size of two strings. (Specify the length)
Function prototype function StrLCopy(Dest, Source: PChar; MaxLen: Cardinal): PChar; Copy string. (Specify length)
Function prototype function StrLen(Str: PChar): Cardinal; pass back the string length. (excluding the terminating bits)
Function prototype function StrLIComp(Str1, Str2: PChar; MaxLen: Cardinals): Integer; Compare the size of two strings. (Specify long, case-free)
Function prototype function StrLower(Str: PChar): PChar; Convert all strings to lowercase letters.
Function prototype function StrMove(Dest, Source: PChar; Count:Cardinal): PChar; Copy n Bytes from the source string to the target r string. (excluding the terminating bits)
Function prototype function StrNew(Str: PChar): PChar; Configure string space.
Function prototype function StrPas(Str: PChar): string; converts the null-terminated string to a Pascal-style string.
Function prototype function StrPCopy(Dest: PChar; Source: string): PChar; Copy the Pascal-style string to the null-terminated string.
Function prototype function StrPLCopy(Dest: PChar; const Source: string; MaxLen: Cardinal): PChar; Copy Pascal-style string to null-terminated string. (Specify length)
Function prototype function StrPos(Str1, Str2: PChar): PChar; The position of the substring in the parent string. (first position) Description Str1 parent string; Str2 substring
Function prototype function StrUpper(Str: PChar): PChar; Convert all strings to capital letters.
StrAlloc Configures a buffer with a maximum length of Size-1 to null ending string function StrAlloc(Size: Word): PChar;
StrBufSize Returns the maximum number of characters that can be stored in the string buffer configured by StrAlloc. StrBufSize( S: PChar): Cardinal;
StrCat joins two strings and passes them back. function StrCat(Dest, Source: PCar): PChar;
StrComp Compare two strings. function StrComp(Str1, Str2: Pchar): Integer;
StrCopy Copy the Source string to Dest. function StrCopy(Dest, Source: PChar): PChar
StrDispose Release a string space. function StrDispose(Str:PChar);
StrECopy Copy the Source string to Dest and pass back a pointer to the end of the string. function StrECopy(Dest, Surce: Pchar): Pchar;
StrEnd Pass back a pointer to the end of the string function StrEnd(Str: Pchar): Pchar;
StrLCat concatenates the Source string to the Dest string and passes back the linked string. function StrLCat(Dest, Source:PCar; MaxLen: Word): PChar;
StrIComp compares the difference between two strings with no case. function StrIComp(Str1, Str2:Pchar): Integer;
StrLComp Compare two strings to the specified maximum length function StrLComp(Str1, Str2:Pchar; MaxLen: Word): Integer;
StrLCopy Copy the specified number of characters from one string to another string Function StrLCopy(Dest,Source:PChar;MaxLen: Cardinal): PChar;
StrLen Returns the length of the string. function StrLen(Str: PChar): Cardinal;
StrLIComp Compares two strings to the specified maximum length without case difference. function StrLIComp(Str1, Str2:PChar; MaxLen: Word):Integer;
StrLower Converts a string to lowercase. function StrLower(Str: PChar):PChar;
StrMove Copy Count character number from Source to Dest string. function StrMove(Dest, Source:PChar; Count: Cardinal): PChar
StrNew configures a string from stacking. function StrNew(Str: PChar):PChar;
StrPas Converts the null ending character into a Pascal format string. function StrPas(Str: Pchar):String;
StrPCopy Copy a Pascal format string to a null-end string. Function StrPCopy(Dest:PChar;Source: String): PChar;
StrPLCopy Copy the number of characters referred to by MaxLen, from Pascal format string to null ending string. Function StrPLCopy(Dest:Pchar;cost Source: string;MaxLen: Word): PChar;
StrPos returns a pointer to the position where the Str2 string first appears in Str1. function StrPos(Str1, Str2: Pchar): Pchar;
StrScan returns a pointer to the first location in the Str string where the chr character appears. function StrScan(Str: PChar; Chr: Char): PChar;
StrRScan Returns a pointer to the position where the chr character appears last in the Str substring. function StrRScan(Str: Pchar; Chr: Char): PChar;
StrUpper converts a string to uppercase. function StrUpper(Str: PChar):PChar;
Date and Time Routines
Unit: SysUtils
Date Return to today's date. function Date: TDateTime;
DateTimeToStr Converts the time format to a string. function DateTimeToStr(DateTime: TDateTime):String;
DateTimeToString Converts the time format to a string. procedure DateTimeToString(var Result: string;const Format: string;DateTime: TDateTime);
DateToStr Converts date format to string. function DateToStr(Date: TDateTime): String;
DayOfWeek is sent back to the day of today. function DayOfWeek(Date: TDateTime): Integer; The value returned is an integer, 1~7. Sunday is 1.
The date specified by the DecodeDate is year, month, and day. procedure DecodeDate(Date: TDateTime;var Year, Month, Day:Word);
DecodeTime Decomposition specifies the date as hours, minutes, and seconds. procedure DecodeTime(Time: TDateTime;var Hour, Min, Sec, MSec: Word);
EncodeDate Returns the date format that combines year, month, and day. function EncodeDate(Year, Month, Day: Word):TDateTime;
EncodeTime Returns the time format that combines time, minutes and seconds. function EncodeTime(Hour, Min, Sec, MSec:Word): TDateTime;
FormatDateTime Returns the date and time in the specified format. function FormatDateTime(const Format: string;DateTime: TDateTime):String;
Now send back the current date and time. function Now: TDateTime;
StrToDate Converts a string to date format. function StrToDate(const S:string): TDateTime;
StrToDateTime Converts a string to date and time format function StrToDateTime(const S: string): TDateTime;
StrToTime Converts a string to time format. function StrToTime(const S:string): TDateTime;
Time is sent back to the present time. function Time: TDateTime;
TimeToStr Converts the time format to a string. function TimeToStr(Time:TDateTime): String;
File management functions
Unit: SysUtils
Function prototype function ExtractFileDir(const FileName: string): string;
Function prototype function ExtractFileDrive(const FileName: string): string;
Function prototype function ExtractFileExt(const FileName: string): string;
Function prototype function ExtractFileName(const FileName: string): string;
Function prototype function ExtractFilePath(const FileName: string): string;
Function prototype function DeleteFile(const FileName: string): Boolean;
Function prototype function RenameFile(const OldName, NewName: string):Boolean;
Function prototype function FileExists(const FileName: string): Boolean;
Function prototype Procedure FindClose(var F: TSearchRec);
Function prototype function FindFirst(const Path: string; Attr: Integer; var F: TSearchRec): Integer;
Function prototype function FindNext(var F: TSearchRec): Integer; indicates that 0 was successfully passed back
ChangeFileExt Change the file extension.
function ChangeFileExt(const FileName,Extension: string):string; DateTimeToFileDate Converts the date format of Delphi to the date format of DOS.
functionDateTimeToFileDate(DateTime:TDateTime): Longint;
DeleteFile Delete a file. function DeleteFile(const FileName: string):Boolean;
DiskFree Returns the free space of the disk. function DiskFree(Drive: Byte): Longint;
DiskSize Returns the capacity size of the specified disk. function DiskSize(Drive: Byte): Longint;
ExpandFileName Returns a complete path and file name string. function expandFileName(const FileName: string):string;
ExtractFileExt The extension to the file is passed back. function ExtractFileExt(const FileName string): string;
ExtractFileName The file name of the file that is passed back. function ExtractFileName(const FileName: string): string;
ExtractFilePath The path to the file being passed back. function ExtractFilePath(const FileName: string):string;
FileAge The age of the file being passed back function FileAge(const FileName: string):Longint;
FileCreate Creates a file with the specified file name. function FileCreate(const FileName: string):Integer;
FileClose Closes the specified file. procedureFileClose(Handle: Integer);
FileDateToDateTime Converts the DOS date format to the Delphi date format. function FileDateToDateTime(FileDate: Longint):TDateTime;
FileExists determines whether the file exists. function FileExists(const FileName: string):Boolean;
FileGetAttr Returns file attributes. function FileGetAttr(const FileName: string):Integer;
FileGetDate and time of the file being returned. function FileGetDate(Handle: Integer): Longint;
FileRead reads data from the specified file. function FileRead(Handle:Integer; var Buffer; Count:Longint):Longint;
FileSearch Searches the specified file in the directory column. function FileSearch(constName, DirList: string): string;
FileSeek Changes the position of the file cursor. function FileSeek(Handle: Integer;Offset: Longint;Origin: Integer):Longint;
FileSetAttr Sets file properties. function FileSetAttr(const FileName: string;Attr:Integer): Integer;
FileSetDate Sets the date and time of the file. procedure FileSetDate(Handle: Integer; Age:Longint);
FileOpen Open file. function FileOpen(const FileName: string; Mode:Word): Integer;
FileWrite Write information to the file. function FileWrite(Handle:Integer;const Buffer; Count:Longint): Longint;
FindClose terminates the first/next action. procedure FindClose(var SearchRec: TSearchRec);
FindFirst Finds the first matching file and sets its properties.
function FindFirst(const Path: string;Attr: Word; var F:TSearchRec): Integer;
FindNext Returns the next matching file. function FindNext(var F:TSearchRec): Integer;
RenameFile Changes the file name. function RenameFile(const OldName,NewName: string):Boolean;
Transfer Routines
Unit: System
Chr returns the characters corresponding to the ASCII code. function Chr(X: Byte): Char;
Delphi source code task (http://home.kimo.com.tw/bruce0211/) typing 15
High Returns the highest value of the parameter in the range. function High(X);
Low Returns the lowest value of the parameter in the range. function Low(X);
Ord returns the order value corresponding to an ordered pattern. function Ord(X): Longint;
Round Round a real value and passes it back to the integer value. function Round(X: Real):Longint;
Trunc de-tail a real value and passes it back to the integer value. function Trunc(X: Real):Longint;
pred(x) pred('D')='C', pred(true)=1;
succ(x) succ('Y')='Z', succ(pred(x))=x
ord(x) Find the sequence number of x in the character set, such as ord('A')=65
chr(x) chr(65)='A'
round(x) round(x)
trunc(x) trunc(4.8)=4,trunc('-3.6')=-3
upcase(x) upcase('a')='A'
hi(I) hi($2A30)=$2A
lo(I) lo($2A30)=$30
random(n) produces random integers between [0,n)
sizeof(name) Finds the number of bytes occupied by a certain type or variable in memory
swap(num) swap the high and low bits of int swap($3621)=$2136
Frac Find the fractional part of a real number
R := Frac(123.456); { 0.456 }
R := Frac(-123.456); { -0.456 }
Int Find the integer part of a real number
R := Int(123.456); { 123.0 }
R := Int(-123.456); { -123.0 }
Function prototype function High(X); pass back the maximum value of the footnote
Function prototype function Low(X); Low Pass back the minimum value of the footnote.
Function prototype function Ord(X): Longint; Returns the numerical value of the enumeration pattern.
Function prototype function Round(X: Extended): Longint; Convert real numbers into integers. (rounded)
Function prototype function Trunc(X: Extended): Longint; Convert real numbers into integers. (Discard decimals directly)
Function prototype function VarArrayCreate(const Bounds: array of Integer; VarType: Integer): Variant; Create a variant array.
Function prototype function VarArrayOf(const Values: array of Variant): Variant; Create a simple one-dimensional variant array
Function prototype function VarArrayLock(var A: Variant): Pointer; Assign variant array ==> to an array variable.
Function prototype procedure VarArrayUnlock(var A: Variant); Unlock the above specification.
Function prototype function VarIsArray(const V: Variant): Boolean; Returns whether Variant is an array.
Function prototype function VarIsNull(const V: Variant): Boolean; Return whether Variant is NULL.
Function prototype function VarAsType(const V: Variant; VarType: Integer): Variant; Convert Variant to another type of Variant.
Function prototype procedure VarCast(var Dest: Variant; const Source: Variant; VarType: Integer); indicates that VarType cannot be varArray or varByRef.
Function prototype function VarType(const V: Variant): Integer; Return to the Variant pattern.
Function prototype procedure VarClear(var V: Variant); Clear variant and become Unassigned.
Function prototype procedure VarCopy(var Dest: Variant; const Source: Variant); Copy a variant. The description is the same as Dest:=Source;.
Function prototype function VarFromDateTime(DateTime: TDateTime): Vari ant; Convert DateTime to Variant.
Function prototype function VarToDateTime(const V: Variant): TDateTime; convert Variant to DateTime.
Function prototype function Hi(X): Byte; Return high-digit number.Hi($1234); { $12 }
Function prototype procedure Include(var S: set of T; I:T); Instructions to add I elements to S. Add an element to a group of elements.
Function prototype function Lo(X): Byte; Lo($1234); { $34 }
Function prototype Procedure Move(var Source, Dest; Count: Integer); Copy n Bytes from source variables to destination variables.
Function prototype function ParamCount: Integer; directly adds the number of variables passed from the execution file.
Function prototype function ParamStr(Index: Integer): string;Describe ParamStr(0);Transfer back to the name and complete directory of the execution file.
Function prototype function Random [ ( Range: Integer) ]; Description 0<=X<Range
Function prototype function Swap(X); Swap exchanges high and low bits of a set of variables.
Function prototype function UpCase(Ch: Char): Char; Convert one character to capital letters.
Function prototype procedure Dec(var X[ ; N: Longint]);Dec(X) ==> X:=X-1; Dec(X,N) ==> X:=XN; Decrease variables.
Function prototype procedure Inc(var X [ ; N: Longint ] ); Description Inc(X) ==> X:=X-1;Inc(X,N) ==> X:=XN; Increment variables.
Function prototype function Odd(X: Longint): Boolean; Check whether it is an odd number.
Function prototype function Assigned(var P): Boolean; Assigned Test whether the pointer variable is nil. Explain when @P=nil ==> is passed back to FALSE
Mathematical functions
Abs returns the absolute value of the parameter. function Abs(X);
ArcTan returns the inverse value of the tangent function. function ArcTan(X: Real): Real;
Cos Returns the cosine function value function Cos(X: Real): Real; (X in radians).
Exp passes back the natural index value. function Cos(X: Real): Real;
Frac returns the decimal part of the parameter. function Frac(X: Real): Real;
Int Returns the integer part of the parameter. function Int(X: Real): Real;
Ln returns natural logarithmic value. function Ln(X: Real): Real;
Pi transfers back the value of pi. function Pi: Real;
Sin passes back the sine function value. function Sin(X: Real): Real;
Sqr returns the square of the parameters. function Sqr(X: Real): (Real);
Sqrt returns the square root of the parameter. function Sqrt(X: Real): Real;
Output function Unit: System
AssignFile Specifies a file to file variable. procedure AssignFile(var f, String);
CloseFile Close the file. procedure CloseFile(var F);
Eof determines whether the file has reached the end.
Typed or untyped files: functionEof(var F): BooleanText files:function Eof [ (var F: Text) ]:Boolean;
Erase Clears file contents. procedure Erase(var F);
FilePos returns the current file cursor location. function FilePos(var F): Longint;
FileSize The size of the file is passed back function FileSize(var F):Longint;
GetDir Returns the working directory of the specified disk. procedure GetDir(D: Byte; var S: String);
IOResult Returns the state of the last I/O execution. function IOResult: Integer;
MkDir Create a subdirectory. procedure MkDir(S: String);
Rename Changes the file name of the external file. procedure Rename(var F; Newname);
Reset Opens an existing file. procedure Reset(var F [: File; Recsize: Word ] );
Rewrite Create and open a new file. procedure Rewrite(var F: File [; Recsize: Word ] );
RmDir Delete an empty directory. procedure RmDir(S: String);
Seek Move file cursor. procedure Seek(var F; N: Longint);
Truncate deletes the file contents in the current location. procedure Truncate(var F);
Floating point number conversion function Unit: SysUtils
FloatToDecimal transfers the floating point value into decimal and integer parts to numbers.
procedure FloatToDecimal(var Result: TFloatRec;Value:Extended;Precision, Decimals:Integer);
FloatToStrF converts floating point numbers into string descriptions according to the specified format.
function FloatToStrF(Value: Extended; Format:TFloatFormat;Precision,Digits: Integer): string;
FloatToStr Converts a floating point number into a string description. function FloatToStr(Value: Extended): string;
FloatToText The given floating point value is transferred back into decimals and integer parts according to the format.
function FloatToText(Buffer: Pchar; Value:Extended;Format:TFloatFormat;Precision,Digits: Integer): Integer;
FloatToTextFmt converts the floating point number into a string according to the format and passes it back.
function FloatToTextFmt(Buffer: PChar; Value:Extended;Format: PChar) :Integer;
FormatFloat passes the floating point value back in Format format.
function FormatFloat(constFormat: string;Value:Extended):string;
StrToFloat converts the given string into a floating point value.
function StrToFloat(const S: string): Extended;
TextToFloat converts a null ending string into a floating point value
function TextToFloat(Buffer: PChar;var Value:Extended): Boolean;
Process control function Unit: System
Break terminates the loop. Such as for, while and repeat loops.
Continue Continue the loop. Such as for, while and repeat loops.
Exit leaves the current block. procedure Exit;
Halt stops the execution of the program and returns to the operating system.
Dynamic configuration function Unit: System
Dispose Release a dynamic variable. procedure Dispose(var P: Pointer);
Free Release a copy of the object. procedure Free;
FreeMem Releases a dynamic variable of a given size. procedure FreeMem(var P:Pointer; Size: Word);
GetMem Creates a dynamic variable of a specified size and passes it back to the address by the Pointer parameter. procedure GetMem(var P:Pointer; Size: Word);
New Creates a new dynamic variable and points the Pointer parameter to it. procedure New(var P: Pointer); function New(<pointer type>):Pointer;
MaxAvail returns the largest configurable space in succession. function MaxAvail: Longint;
MemAvail returns all configurable space. function MemAvail: Longint;
Pointer and address functions Unit: System
addr Returns the address of the specified object. function Addr(X): pointer;
Assigned Determine whether a function or program is nil function Assigned(var P):Boolean;
CSeg returns the contents of the CS program segment register. function CSeg: Word;
DSeg returns the contents of the DS data segment temporary register. function DSegt: Word;
Ofs The offset address of the parameter is returned. function Ofs(X): Word;
Ptr combines the specified segment and offset address into a pointer. function Ptr(Seg, Ofs: Word):Pointer;
Seg returns the segment address of the parameter. function Seg(X): Word;
SPtr returns the contents of the SP stacking register. function SPtr: Word;
SSeg returns the contents of the SS stack segment register. function SSeg: Word;
Console function Unit: WinCrt
AssignCrt Connects text files to a console window. procedure AssignCrt(var f: Text);
ClrEol Clears all characters attached to the cursor position to the last line. procedure ClrEol;
ClrScr Clear the screen and reset the cursor to the upper left corner. procedure ClrScr;
CursorTo moves the cursor to the given coordinate. procedure CursorTo(X, Y:Integer);
DoneWinCrt End the console window. procedure DoneWinCrt;
GotoXY Moves the cursor to the given coordinate. procedure GotoXY(X, Y: Byte);
InitWinCrt Creates a console window. procedure InitWinCrt;
KeyPressed Determines whether there is a key. function KeyPressed:Boolean;
ReadBuf reads a line from the console window. function ReadBuf(Buffer: Pchar;Count: Word):
ReadKey Reads key characters. function ReadKey: Char;
ScrollTo Scroll the console window to the display position. procedure ScrollTo(X, Y: Integer);
TrackCursor Scroll console window should be visible to the cursor. procedure TrackCursor;
WhereX returns the X coordinate of the cursor. function WhereX: Byte;
WhereY returns the Y mark of the cursor. function WhereY: Byte;
WriteBuf Writes a block of characters to the console window. procedure WriteBuf
WriteChar Write a character to the console window. procedure WriteChar(CH: Char);