ABS (X) absolute value arctan (x) Annute orthogonal COS (X) transmission back Strove function EXP (X) E X - power FRAC (X) Take a small number of int (x) Removal Ln (X) Natural pair Number SIN (X) transmission back sinusoid function value SQR (x) x * x SQRT (x) square root other PRED (X) PRED ('d') = 'c', PRED (TRUE) = 1; SUCC (X) SUCC ('Y') = 'z', SUCC (PRED (x)) = x ORD (X) See the serial number in the character set, such as ORD ('A') = 65 CHR (X) CHR (65) = ' A 'Round (x) rounded 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) Generates Random Integers between [0, N) SIZEOF (NAME) to find a number of bytes occupying a type or variable SWAP (NUM) SWAP ($ 3621) = $ 2136 ==================================================================================================================================================================== ========================= ABS absolute value ---------------------- ----------------------------------- Unit system Function prototype FUNCTION ABS (X); Description X is an integer OR implementation. Example Var r: real; i: integer; begin r: = ABS (-2.3); {2.3} i: = ABS (-157); {157} END;
-------------------------------------------------- -------- Arctan triangle function ------------------------------------- ------------------- Example Cos Var r: extended; begin r: = COS (PI); END; ------------- -------------------------------------------------------------------------------------------------------- -------------------------------------------------- ---- Example Var r: Extended; S: String; Begin R: = SiN (Pi); STR (R: 5: 3, S); Canvas.Textout (10, 10, 'THE SIN OF PI IS' S); END; --------------------------------------------- ------------- Unit System Function Prototype Function Arctan (x: Extended): Extended; Function Prototype Function Cos (X: Extended): Extended; Function Prototype Function SIN (X: Extended): Extended ; ------------------------------------------------- --------- Description X is the diameter . TAN (x) === sin (x) / cos (x) arcsin (x) = Arctan (x / sqrt (1-sqr (x))) Arccos (x) = arctan (SQRT (1-SQR (X) ) / x) The three are not a function, but the right operation is obtained. Example Var r: extended; begin R: = Arctan (PI); END; sample var r: extended; s: string; begin r: = SIN (PI); STR (R: 5: 3, S); Canvas.Textout (10, 10, 'The SiN OF PI IS' S); end;
-------------------------------------------------- -------- FRAC seeks a decimal part of a real number ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------ Unit system function prototype Function Frac (x: real): real; Description X is real. Example Var r: real; begin R: = FRAC (123.456); {0.456} r: = Frac (-123.456); {-0.456} end; ------------------------ ----------------- INT seeks a real number of integers ------------------------ ----------------- Unit System Function Prototype Function Int (x: Real): REAL; Description X is real. Example Var r: real; begin r: = int (123.456 ); {123.0} r: = int (-123.456); {-123.0} end; -------------------------------------------------------------------------------------------------------------------------- ------------ Pi is the pi of mathematics ------------------------------- --------- Unit system Function prototype Function PI: Extended; Description it is a function, but we use it as a preset variable! Pi = 3.1415926535897932385 ---------------------------------------------------------------------- ---------------------------------------------- ------------------- Example Var S, Temp: string; Begin Str (SQR (5.0): 3: 1, TEMP); S: = '5 Squared IS' TEMP # 13 # 10; STR (SQRT (2.0): 5: 4, TEMP); s: = S 'The Square Root of 2 IS' TEMP; Messagedlg (S, Mtinformation, [Mbok], 0) ;
----------------------------------------- SQRT X square root ----- ------------------------------------- Unit system function prototype Function SQR (x: extended): Extended Function prototype Function SQRT (x: extended): Extended; example var s, temp: string; begin Str (SQR (5.0): 3: 1, TEMP); s: = '5 squared is' TEMP # 13 # 10; STR (SQRT (2.0): 5: 4, TEMP); s: = S 'The Square Root of 2 IS' TEMP; Messagedlg (s, mtinformation, [mbok], 0); end; --------------------------------------- LN Natural logar ------- ---------------------------------- Example Var E: Real; s: string; begin E: = EXP (1.0); STR (ln (e): 3: 2, s); s: = 'e =' floattostr (e) '; ln (e) =' s; canvas.textout (10, 10, S); End; -------------------------------------- EXP Index ------ ----------------------------------- Unit system system function prototype Function LN (x: real): real; Function prototype Function Exp (X: REAL): REAL; Example Var E: Real; S: String; Begin E: = Exp (1.0); STR (LN (E): 3: 2, S); s: = 'LN (e) = ' s; canvas.textout (10, 10, s); end;
----------------------------------------- Date and Time Routines Date and Time Functions ----------------------------------------- Date Retrieves the current date Unit Sysutils Function prototype FUNCTION date: tdatetime; example procedure tform1.button1click (sender: TOBJECT); begin label1.caption: = 'Today is' DateTostr (Date); end; ------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------- Unit sysutils function prototype Function DateTimetostr (DateTime : Tdatetime): String; Sample Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); begin label1.caption: = DateTimetostr (now); End; ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------- DateTimetString Date Time Convert to Custom Strings ----- --------------------------------------------------Unit SysUtils function prototype procedure DateTimeToString (var Result: string; const Format: string; DateTime: TDateTime); Example procedure TForm1.FormCreate (Sender: TObject); var s: string; begin DateTimeToString (s, 'dddd, mmmm d, yyyy "AT" HH: MM AM / PM ', NOW); Label1.caption: = S; END;
The result Friday, December 20,1996 at 09:20 PM -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------- **** Format format . ----------------------------------------------- --------- DateTostr Date Convert into an internal stereotype. (1996/12/20) ------------------------- ------------------------------ Unit sysutils function prototype Function DateTostr (date: tdatetime): string; example procedure tform1.button1click (Sender: TOBET); Begin Label1.caption: = 'Today Is' DateTostr (Date); End; # Date, DateTostr Example --------------------- ----------------------------------- Dayofweek seeks the date of the week. ------ -------------------------------------------------- Unit sysutils function prototype Function Dayofweek (date: tdatetime): Integer; Description The return value is an integer, 1 ~ 7. Sunday is 1. Example Procedure TFORM1.BUTTON1C Lick (Sender: TOBJECT); VAR ADATE: TDATETIME; DAYS: Array [1..7] of string; begin days [1]: = 'sunday'; days [2]: = 'monday'; days [3]: = 'Tuesday'; Days [4]: = 'Wednesday'; Days [5]: = 'Thursday'; Days [6]: = 'friday'; days [7]: = 'Saturday'; adate: = strtodate Edit1.text); showMessage (edit1.text 'is a' days [dayofweek (adate)];
# Stradate, Dayofweek Example --------------------------------------------- ---------- Decodedate changes the date variable to the TDATETIME type, and turn to Word. ------------------------ -------------------------------- Example procedure tform1.button1click (sender: TOBJECT); VAR Present: tdatetime; Year, Month, Day, Hour, min, sec, msec: word; begin present: = now; decodate (present, year, month, day); label1.caption: = 'Today' $ INTOSTR (DAY) 'of Month ' INTSTOSTR (MONTH) ' of year ' INTOSTR (YEAR); Decodetime (Present, Hour, min, sec, msec); label2.caption: =' Time is minute ' INTOSTR (min) of Hour ' INTOSTR (Hour); end; # decodate, decodetime example ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------ Decodetime to turn the TDATETIME type time variable to Word ------------------------------------- ----- Unit sysutils Function Prototype Procedure Decodedate (Date: Tdatetime; VAR Year, Month, Day: Word); Function Prototype Procedure Decodetime (Time: TdateTime; Var Hour, Min, Sec, Msec: Word); Example Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); VAR Present: Tdatetime; Year, Month, Day, Hour, Min, Sec, Msec: Word; Begin Present: = now; decodate (Present, Year, Month, day); label1. CAPTION: = 'Today Is Day'
INTOSTR (DAY) 'of Month' INTOSTR (MONTH) 'of year' INTOSTR (YEAR); Decodetime (Present, Hour, min, sec, msec); label2.caption: = 'the time is minute' INTTOSTR (MIN) 'of Hour' INTOSTR (HOUR); END; ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------ Encodedate changes the date variable to the TDATETIME. ----------- -------------------------------------------- Example Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); var mydate: = encodedate (strt (Edit1.text), Strt (Edit2.Text), start (edit3.text); label1.caption: = DATETOSTR (MyDate); END ; ------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------- -------------------------- Unit SysUtils function prototype function EncodeDate (Year, Month, Day: Word): TDateTime; function prototype function EncodeTime (Hour, Min, Sec, MSec: Word): TDateTime; example procedure TForm1.Button1Click (Sender: TObject); var MyDate: TDateTime Mytime: tdatetime; begin mydate: = encodedate (83, 12, 31); label1.caption: = DATETOSTOSTR (MyDate); mytime: = encodetime (0, 45, 45, 7); label2.caption: = Timetostr (MyTime) ); END; example procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT);
Var myTime: = encodetime: = Encodetime (0, 45, 45, 7); label1.caption: = Timetostr (MyTime); end; -------------------------------------------------------------------------------------------------- ------------------------------------- formatDateTime converts the date time according to Format's format to the word Strings. ------------------------------------------------------------------------------- ------- Unit Sysutils Function Prototype Function FormatdateTime (const format: string; datetime: tdatetime): string; **** Similar to DateTimetostring. Format format C The format of DualDateFormat. (1996/12/20 09 : 20: 15 pm). D Date, not supplemented in front. (1-31) DD date, previously supplemented 0. (01-31) DDD Week. (Sunday). DDDD Chinese version 2.01, the same. DDDD date. 1996/12/20) DDDDDD date. (December 20, 1996) M month, no completion of 0. (1-12) MM, previously added 0. (01-12) mmm Chinese display. (December Mmmm Chinese version 2.01, the same. Yy year. (009) YYYY year. (0000-9999) H hours. (0-23) HH Hours. (00-23) N minutes. (0-59) NN minute. (00-59) s second. (0-59) SS seconds. (00-59) T Time. (09:20 pm) TT time. (09:20:15 pm) AM / PM separately displays AM or PM. (If uppercase, display uppercase) A / P separately displays a or P. example the folload exampleday, february 15, 1995 At 10:30 am 'to the string variable s: = formatdatetime (' "The Meeting is on" DDDD, MMMM D, YYYY, "AT" HH: MM AM / PM ', StrtodateTime (' 2 / 15/95 10:30 am '));
// ??? --------------------------------------------- ----------- NOW Retrieves the current date time. ------------------------------- ------------------------- Unit sysutils function prototype Function now: tdatetime; sample procedure tform1.button1click (sender: TOBJECT); begin label1.caption: = DateTimetostr (now); End; # now, datetimetostr example ------------------------------------- ------------------ Strtodate Date for the string to TDATETIME type. ------------------- ------------------------------------- Unit sysutils function prototype Function Strtodate (const S: String): TDATETIME; Sample Procedure TFORM1.BUTTON1CLICK (Sender: Tobject); var ad date: = strtodate (edit1.text); label1.caption: = DATETOSTR (Adate); END; example Procedure TFORM1 .Button1Click (Sender: TOBJECT); VAR ADATE: TDATETIME; DAYS: Array [1..7] of string; begin days [1]: = 'sunday'; days [2]: = 'monday'; days [3] : = 'Tuesday'; Days [4]: = 'Wednesday'; Days [5]: = 'Thursday'; DAYS [6]: = 'frIDay'; days [7]: = 'SATURDAY'; adate: = strtodate (Edit1.text); showMessage (edit1.text 'is a' days [dayofweek (adate)];
# Stradate, Dayofweek Example --------------------------------------------- ----------- StrtodateTime Time to turn the string to the TDATETIME type. -------------------------- ----------------------------- Unit sysutils function prototype Function StrtodateTime (const s: string): tdatetime; example procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); VAR AdatendTime: TDATETIME; Begin AdatendTime: = StrtodateTime (Edit1.Text); Table1.fieldByname ('TimeStamp'). Asdatetime: = adatendTime; End; -------------- ------------------------------------------ - Strtotime will change the string to TDATETIME type time. ------------------------------------------------------------------------------------------ ------------ Unit sysutils function prototype Function Strtotime (const S: String): tdatetime; sample procedure tform1.button1click (sender: TOBJECT); VAR atime: tdatetime; becom In atime: = strtotime (edit1.text); if atime <0.50 Then ShowMessage ('Good Morning') Else ShowMessage ('Good Afternoon'); End; ---------------- --------------------------------------- Time passed the time. -------------------------------------------------- --- Unit SysUtils function prototype function Time: TDateTime; example procedure TForm1.Timer1Timer (Sender: TObject); var DateTime: TDateTime; str: string; begin DateTime: = Time; // store the current date and time str: =
TimeToStr (DateTime); // convert the time into a string Caption: = str; // display the time on the form's caption {Note This could have been done with the following line of code: Caption: = TimeToStr (Time);} End; # Time, Timetostr Example --------------------------------------------------------------------------------------------------------------------- ------------ Timetostr Time Convert into an internal stereotype. (09:20:15 pm) -------------------- ----------------------------------- Unit sysutils function prototype Function Timetostr (Time: TDATETIME): STRING GetMem Procedure Configuring the memory program NEW Configure the memory space of the native P. ------------------------- -------------------------------- Dispose releases the memory configured by New. -------- ---------------------------------------------- Unit System Function Prototype Procedure New (VAR P: POINTER); Function Prototype Procedure Dispose (VAR P: Pointer); Example Type PListentry; Tlistentry = Record Next: PListentry; Text: string; count: integer; end; var list, p: plistentry; begin ... new (p); p ^ .next: = List; p ^ .text : = 'Hello World'; P ^ .count: = 1; List: = P; ... Dispose (p); ... End; Example Type str18 = string [18]; var P: ^ str18; begin new ); P ^: = '
Now you see it ... '; dispose (p); {now you don't ...} end; ------------------------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------- ----- Example VAR f: File; Size: Integer; Buffer: Pchar; Begin Assignfile (f, 'Test.txt'); Reset (f, 1); try size: = filesize (f); getMem (buffer , Size); Try BlockRead (f, buffer ^, size); processfile (buffer, size); Finally FreeMem (Buffer); end; fin or closefile (f); end; end; ---------- -------------------------------------------- FreeMem Release GetMem Configured memory. ----------------------------------------------- ----------- Unit System Function Prototype Procedure GetMem (VAR P: POINTER; SIZE: Integer); Function Prototype Procedure FreeMem (VAR P: Pointer [; Size: Integer]); Example VAR F: File; Size: Integer; Buffer: Pchar; Begin AssignFile F, 'Test.txt'); Reset (f, 1); try size: = filesize (f); getMem (buffer, size); Try BlockRead (f, buffer ^, size); processfile (buffer); Finally FreeMem (Buffer); end; fin or closefile (f); end;
================================================================================================================================================================== ============================== -------------------- ------------------------------------ Changefileext Change Archive ------- ------------------------------------ SysUtils function prototype function ChangeFileExt (const FileName, Extension: string): string; example procedure TForm1.Button1Click (Sender: TObject); var S: String; P1: String; P2: String; begin P1: = 'abc.txt'; P2: = '. Ini'; s: = ChangefileExt (P1, P2); Label1.caption: = S; END; Results S == 'Abc.ini'
P1: = 'ABC' P2: = '. INI' S == 'Abc.ini'
P1: = 'c: /windows/abc.txt' P2: = '. INI' S == 'C: /Windows/abc.ini'
P1: = 'abc.txt' P2: = 'INI' S == 'Abcini' ** Note: The first element of P2 must have a little '.ini' example procedure TFORM1.CONVERTICON2BITMAPCLICK (Sender: TOBJECT);
Var s: string; icon: ticon; begin
OpenDialog1.default: = '.ico';
OpenDialog1.Filter: = 'icons (* .ico) | * .ICO'; OpenDialog1.Options: = [ofOverwritePrompt, ofFileMustExist, ofHideReadOnly]; if OpenDialog1.Execute then begin Icon: = TIcon.Create; try Icon.Loadfromfile (OpenDialog1 .Filename); s: = ChangefileExt (OpenDialog1.FileName, '. BMP'); image1.width: = icon.width; image1.height: = icon.de; image1.canvas.draw (0, icon); Image1.Picture.SaveToFile (s); ShowMessage (OpenDialog1.FileName 'Saved to' s); finally Icon.Free; end; end; end; # SaveToFile, Create, Height, Width, Canvas, ChangeFileExt example --- -------------------------------------------------- --- ExpandFileName plus the file name after the current path of the current ,------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ---------------------- Unit sysutils function prototype Function ExpandFileName (const filename: string): String; Description Set the current directory to the C: / Windows file name is abc.txt result is C: /Windows/abc.txt **** This function is not asking for ABC.TXT's path. Sample procedure tform1.button1click (sender: Tobject); var s: string; begin s: = expandFileName ('abc.txt'); label1.caption: = s; end; example procedure tform1.button1click (Sender: TOBJECT) Begin ListBox1.Items.Add (EXPANDFILENAME (EDIT1.TEXT));
-------------------------------------------------- --------------- DirectoryExists directory exists ---------------------------- ------------------------------------ Unit FileCtrluses FileCtr1;
Procedure tForm1.Button1Click (Sender: Tobject); Begin if Not Directoryexists ('C: / Temp') Then IF Createdir ('C: / Temp') Then Raise Exception.create ('Cannot Create C: / Temp'); End; ---------------------------------------------------------------- -------- Forcedirectories directory ------------------------------------------------------------------------------------ ----------------- Unit FileCtrl Function Prototype Function Forcedirectories (Dir: String): Boolean;
Procedure TForm1.Button1Click (Sender: Tobject); var dir: string; begin dir: = 'c: / apps / sales / local'; if Directoryexists (dir) Then Label1.caption: = DIR 'WAS CREATED' end; -------------------------------------------------- ----- ExpanduncFileName is the same as above (just get the path on the Internet) --------------------------------- -------------------- Unit sysutils function prototype Function ExpanduncFileName (const filename: string): String; ExtractFileDir Analysis string Path Unit sysutils Function Prototype Function ExtractFileDir Const filename: string: String; Description Set the s string is c: /windows/abc.txt result is the result of the C: / Windows **** function is to analyze its path to analyze its path Sample Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); var s: string; p1: string; begin p1: = 'c: /windows/abc.txt'; S: = extractfiledir (p1); label1.caption: = S; end; s == 'c: / windows'
P1: = 'abc.txt' s == '
P1: = 'c: abc.txt' s == 'c:'
P1: = 'c: /abc.txt' s == 'c: /' ------------------------------- ------------------------- ExtractFileDrive Analysis String DVD in the string --------------- ---------------------------------------- Unit sysutils function prototype Function ExtractFileDrive (Const FileName) : String; **** functionally, only back the disk machine name. Example procedure tform1.button1click (sender: TOBJECT); var s: string; p1: string; begin p1: = 'c: / windows /Abc.txt '; s: = extractfiledrive (p1); label1.caption: = S; end; s: =' c: '
P1: = 'abc.txt' s == '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------- Unit sysutils function prototype Function ExtractFighExt (const filename: string): String ; Example procedure tform1.button1click (sender: TOBJECT); var s: string; p1: string; begin p1: = 'c: /windows/abc.txt'; s: = extractfileext (p1); label1.caption: = s ;
S == '. Txt'
P1: = 'c: / windows / abc' s == 'example myfilesextension: = extractfileext (myfilename); -------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------- - Unit SysUtils function prototype function ExtractFileName (const FileName: string): string; example procedure TForm1.Button1Click (Sender: TObject); var S: String; P1: String; begin P1: = 'c: /windows/abc.txt' ; S: = extractFileName (P1); label1.caption: = s; end;
S == 'abc.txt' paradigm procedure TForm1.Button1Click (Sender: TObject); var BackupName: string; FileHandle: Integer; StringLen: Integer; X: Integer; Y: Integer; begin if SaveDialog1.Execute then begin if FileExists ( SaveDialog1.FileName) then begin BackupName: = ExtractFileName (SaveDialog1.FileName); BackupName: = ChangeFileExt (BackupName, '.BAK'); if not RenameFile (SaveDialog1.FileName, BackupName) then raise Exception.Create ( 'Unable to create backup . file '); end; FileHandle: = FileCreate (SaveDialog1.FileName); {Write out the number of rows and columns in the grid.} FileWrite (FileHandle, StringGrid1.ColCount, SizeOf (StringGrid1.ColCount)); FileWrite (FileHandle , StringGrid1.RowCount, SizeOf (StringGrid1.RowCount)); for X:? = 0 to StringGrid1.ColCount 1 do begin for Y: = 0 to StringGrid1.RowCount 1 do begin {Write out the length of each string, followed by the? string itself} StringLen:. = Length (StringGrid1.Cells [X, Y]); FileWrite (FileHandle, StringLen, SizeOf (StringLen)); FileWrite (FileHandle, StringGrid1.Cells [X, Y], Length (StringGrid1.Cells [ X, y]); end; end; fileclose (filehandle); end;
## FileExists, Renamefile, FileCreate, FileWrite, FileClose, ExtractFileName Example ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------- ------------------------------- Unit sysutils function prototype Function ExtractFilePath (const filename: String): String; Description The result is the result of C: /Windows/abc.txt, the result is C: / Windows example procedure TFORM1.BUTTON1CLICK (Sender: Tobject); var s: string; p1: string; begin p1: = 'c: / windows / abc .txt '; s: = extractfilepath (p1); label1.caption: = s; end; example begin with session do beg, configmode: = cmsession; try addstandardalias (' tempdb ', extractfilepath (paramstr (0)),' paradox ' Finally configmode: = Cmall; end; end; ## configmode, addstandardalias, extractfilepath example ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -------------------- FileSearch looks for the correct path in the disk in the disk ------------------- ------------------------------------- Unit sysutils function prototype Function FileSearch (Const Name, Dirlist: String : string; example var s: string; begin s: = filesearch ('abc.txt', 'c: / window /'); label1.caption: = S; end;
Note Find back C: /Window/abc.txt Can't pass the empty string. Example procedure tform1.button1click (sender: TOBJECT); var buffer: array [0..255] of char; filetofind: string; begin GetWindowsDirectory (buffer, SizeOf (buffer)); FileToFind: = FileSearch (Edit1.Text, GetCurrentDir ';' buffer); if FileToFind = 'then ShowMessage (' Could not find ' Edit1.Text ' '.) Else ShowMessage ('Found' FileTofind '); End; ## filesearch, ShowMessage Example ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------- Unit sysutils Function Prototype Function Fileage (const filename: String): Integer; Description is the modification date of the archive content wrap surface in the archive. Example procedure tform1.button1click (sender: TOBJECT); var S: ST ring; FileDate1: Integer; DateTime1: TDateTime; begin FileDate1: = FileAge ( 'c: /delphi_d/delphi_help1.txt'); DateTime1: = FileDateToDateTime (FileDate1); S: = DateTimeToStr (DateTime1); Label1.Caption: = S ; END; ----------------------------------------------- -------- FileDateTodateTime converts the DOS type date time to TDATETIME type. --------------------------- ---------------------------- Unit sysutils function prototype Function FileDateTodateTime (FileDate: Integer): TDATETIME
-------------------------------------------------- -------------------------- DateTimetOfileDate converts the datetime of the TDATETIME type to a DOS type. --------- -------------------------------------------------- ----------------- Unit sysutils function prototype Function DateTimetOfileDate (datetime: tdatetime): Integer; filegetdate Retrieves the date and time (DOS type) of the file (DOS). Function prototype function FileGetDate (Handle: Integer): Integer; modified date is described in Item Explorer content batter examples procedure TForm1.Button1Click. (Sender: TObject); var FileHandle: Integer; S: String; FileDate1: Integer; DateTime1: TDateTime Begin FileHandle: = FileOpen ('c: /delphi_d/delphi_help2.txt', fmopenreadwrite); if FileHandle> 0 Then Begin filedate1: = filegetdate (filehandle); DateTime1: = fileDatetodatetime (Fileda) TE1); s: = DateTimetostr (DateTime1); fileclose (fileHandle); end else s: = 'open file error'; label1.caption: = s; end; -------------- -------------------------------------------------- ------------ FileSetDate Set the date and time (DOS type). ----------------------- -------------------------------------------------- ---- Unit sysutils function prototype Function FileSetdate (Handle: Integer; Age: Integer): Integer;
Note The return value is 0 means success. ----------------------------------------- ----------------------------------- Deletefile Delete Archive ----------- -------------------------------------------------- ---------------- Unit sysutils function prototype Function deletefile (const filename: string): boolean; example one deletefile ('delete.me ");
Sample IF FileExists (FileName) THEN IF Messagedlg ('Do You Really Want To Delete' ExtractFileName (filename) '?'), []) = IDYES TEN DELETEFILE (FileName); ## fileexists, deletefile example --- -------------------------------------------------- ------------------------ RenameFile changes the name ---------------------- -------------------------------------------------- ----- Unit SysUtils function prototype function RenameFile (const OldName, NewName: string): Boolean; example procedure TForm1.Button1Click (Sender: TObject); var BackupName: string; FileHandle: Integer; StringLen: Integer; X: Integer; Y: integer; Begin if Savedialog1.execute the Begin if FileExists (SaveDialog1.FileName) then begin BackupName: = ExtractFileName (SaveDialog1.FileName); BackupName: = ChangeFileExt (BackupName, '.BAK'); if not RenameFile (SaveDialog1.FileName, BackupName) then raise Exception.Create ( 'Unable . to create backup file '); end; FileHandle: = FileCreate (SaveDialog1.FileName); {Write out the number of rows and columns in the grid.} FileWrite (FileHandle, StringGrid1.ColCount, SizeOf (StringGrid1.ColCount));
FileWrite (FileHandle, StringGrid1.RowCount, SizeOf (StringGrid1.RowCount)); for X:?? = 0 to StringGrid1.ColCount 1 do begin for Y: = 0 to StringGrid1.RowCount 1 do begin {Write out the length of each string , followed by the string itself} StringLen:. = Length (StringGrid1.Cells [X, Y]); FileWrite (FileHandle, StringLen, SizeOf (StringLen)); FileWrite (FileHandle, StringGrid1.Cells [X, Y], Length ( Stringgrid1.cells [x, y]); end; end; fileclose (filehandle); end; end; --------------------------- -------------------------------------------------- DiskFree disk (Bytes) ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------- Unit sysutils function prototype Function DiskFree (D Rive: Byte): Integer; example var s: string; begin s: = INTOSTR (Diskfree (0) Div 1024) 'kbytes free.'; label1.caption: = S; end; Description Drive 0 = Current DVC , 1 = A disk machine, 2 = B disk machine ... return value is -1, indicating that the disk machine detection error is indicated. Example Var s: string; amtfree: int64; Total: int64; begin amtfree: = DiskFree (0); Total: = disksize (0); s: = INTOSTR (AMTFree Div Total) 'Percent of the space on drive 0 is free:' (Amtfree Div 1024) 'KBytes Free.';
Canvas.TextOut (10, 10, s); end; ## diskfree, disksize example ------------------------------------------------------------------------------------------------------- --------------------------------------------- Disksize disk machine Space size (bytes) ------------------------------- ------------------------------ Unit sysutils function prototype Function Disks (Drive: Byte): Integer; sample var s: String; Begin S: = INTOSTR (Disksize (0) Div 1024) 'KBytes Free.'; Label1.caption: = S; END; Description Drive 0 = Current Solver, 1 = A disk, 2 = B Disk machine .... If it is -1, it represents a disk detection error. ## diskfree, Disksize Example --------------------- -------------------------------------------------- ------ FileExists Judging whether the file exists. -------------------------------------- -------------------------------------- Unit sysutils function prototype FUNCTION FILEEXISTS (Const FileName: String : Boolean; Similarly FileExists, RenameFile, FileCreate, FileWrite, FileClose, ExtractFileName Example Example procedure TForm1.Button1Click (Sender: TObject); var BackupName: string; FileHandle: Integer; StringLen: Integer; X: Integer; Y: Integer; begin if SaveDialog1.Execute THEN BEGIN if FileExists (Savedialog1.FileName).
if not RenameFile (SaveDialog1.FileName, BackupName) then raise Exception.Create ( 'Unable to create backup file.'); end; FileHandle: = FileCreate (SaveDialog1.FileName); {Write out the number of rows and columns in the grid .} FileWrite (FileHandle, StringGrid1.ColCount, SizeOf (StringGrid1.ColCount)); FileWrite (FileHandle, StringGrid1.RowCount, SizeOf (StringGrid1.RowCount)); for X:? = 0 to StringGrid1.ColCount 1 do begin for Y: = 0 to StringGrid1.RowCount 1 do begin {Write out the length of each string, followed by the string itself.} StringLen:? = length (StringGrid1.Cells [X, Y]); FileWrite (FileHandle, StringLen, SizeOf (StringLen )); FileWrite (FileHandle, StringGrid1.cells [x, y], length (STR) Inggrid1.cells [x, y]); end; end; fileclose (fileHandle); end; end; ## fileexists, deletefile example ## fileexists, renamefile, filecreate, filewrite, fileclose, extractFileName Example ------- -------------------------------------------------- ------------------- Fileopen Opening. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------- - Unit sysutils function prototype Function FileOpen (const filename: string; Mode: integer): Integer;
**** Failed to return -1. Description The following related file readings are low-order, such as the part of the file in DOS INT 21h. FmopenRead = $ 0000; FmopenWrite = $ 0002; fmshareCompat = $ 0000; fmsharecompat = $ 0000; FMShareExClusive = 0010; fmsharednywrite = $ 0020; fmsharedenyread = 0030; fmsharednynone = $ 0040;
fmOpenRead Open for read access only. FmOpenWrite Open for write access only. FmOpenReadWrite Open for read and write access. fmShareCompat Compatible with the way FCBs are opened. fmShareExclusive Read and write access is denied. fmShareDenyWrite Write access is denied. fmShareDenyRead Read access is denied . fmShareDenyNone Allows full access for others example procedure OpenForShare (const FileName: String); var FileHandle:. Integer; begin FileHandle: = FileOpen (FileName, fmOpenWrite or fmShareDenyNone); if FileHandle> 0 then {valid file handle} else {Open error : FileHandle = Negative Dos Error Code} End; Example Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); var iFileHandle: Integer; iFileLength: Integer; iBytesRead: Integer; Buffer: PChar; i: Integer begin if OpenDialog1.Execute then begin try iFileHandle: = FileOpen (OpenDialog1.FileName, fmOpenRead); iFileLength: = FileSeek (iFileHandle, 0,2); FileSeek (iFileHandle , 0,0); Buffer: = PChar (AllocMem (iFileLength 1)); iBytesRead = FileRead (iFileHandle, Buffer, iFileLength); FileClose (iFileHandle); for i: = 0 to iBytesRead-1 do begin StringGrid1.RowCount: = StringGrid1.rowcount
1; stringgrid1.cells [1, i 1]: = buffer [i]; stringgrid1.cells [2, i 1]: = INTOSTR (Integer (buffer [i])); end; finally freemem (buffer); End; end; end; ## fileopen, fileseek, fileread example ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ----------------------------------------- FileCreate file ------ -------------------------------------------------- --------------------- Unit sysutils function prototype Function Filecreate (const filename: string): integer; example procedure tform1.button1click (sender: TOBJECT); VAR backupname: String; "Stringlen: Integer; x: integer; y: integer; begin if Savedialog1.execute1, need, hardenexists (Savedialog1.FileName) THEN BEGI n backupname: = extractialog1.filename; backupname: = changeext (backupname, '.bak'); if not renamefile (Savedialog1.FileName, Backupname) THEN
raise Exception.Create ( 'Unable to create backup file.'); end; FileHandle: = FileCreate (SaveDialog1.FileName); {Write out the number of rows and columns in the grid.} FileWrite (FileHandle, StringGrid1.ColCount, SizeOf (StringGrid1.ColCount)); FileWrite (FileHandle, StringGrid1.RowCount, SizeOf (StringGrid1.RowCount)); for X:? = 0 to StringGrid1.ColCount 1 do beginfor Y: = 0 to StringGrid1.RowCount 1 do begin {Write? out the length of each string, followed by the string itself} StringLen:. = length (StringGrid1.Cells [X, Y]); FileWrite (FileHandle, StringLen, SizeOf (StringLen)); FileWrite (FileHandle, StringGrid1.Cells [X , Y], lonth (stringgrid1.cells [x, y]); end; end; fileclose (fileh ANDLE);
End; ## FileExists, Renamefile, FileCreate, FileWrite, FileClose, ExtractFileName Example ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------ FileClose Off ---- -------------------------------------------------- ----------------------- Unit sysutils function prototype Procedure FileClose (Handle: Integer); Sample Procedure TFORM1.BUTTON1CLICK (Sender: Tobject); var backupname: String ; FileHandle: Integer; StringLen: Integer; X: Integer; Y: Integer; begin if SaveDialog1.Execute then begin if FileExists (SaveDialog1.FileName) then begin BackupName: = ExtractFileName (SaveDialog1.FileName); BackupName: = ChangeFileExt (BackupName, '.Bak'); if not renamefile (Savedialog1.filename, Backupname) THEN raise Exception.Create ( 'Unable to create backup file.'); end; FileHandle: = FileCreate (SaveDialog1.FileName); {Write out the number of rows and columns in the grid.} FileWrite (FileHandle, StringGrid1.ColCount, SizeOf (Stringgrid1.colcount); FileWrite (FileHandle, StringGrid1.Rowcount); for x: = 0 to stringgrid1.colcount? 1 do beg Y: =
? 0 to StringGrid1.RowCount 1 do begin {Write out the length of each string, followed by the string itself.} StringLen: = Length (StringGrid1.Cells [X, Y]); FileWrite (FileHandle, StringLen, SizeOf (StringLen) FileWrite (FileHandle, StringGrid1.cells [x, y], length (stringgrid1.cells [x, y]); end; end; fileclose (filehandle); end; end; ## fileexists, renamefile, filecreate, filewrite, FileClose, extractFilename Example ==================================================== ** ** It is Handle as a number. ======================================== ==== FileRead read the file -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------- Unit sysutils function prototype Function FileRead (Handle: Integer; Var Buffer; Count : INTEGER: in Teger; Sample Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT);
var iFileHandle: Integer; iFileLength: Integer; iBytesRead: Integer; Buffer: PChar; i: Integer begin if OpenDialog1.Execute then begin try iFileHandle: = FileOpen (OpenDialog1.FileName, fmOpenRead); iFileLength: = FileSeek (iFileHandle, 0,2 Fileseek (ifilehandle, 0); buffer: = pchar (instocmelength 1)); ibytesread = fileread (ifilehandle, buffer, ifilength); FileClose (ifilehandle); for i: = 0 to ibytesread-1 do Begin stringgrid1.rowcount: = stringgrid1.rowcount 1; stringgrid1.cells [1, i 1]: = buffer [i]; stringgrid1.cells [2, i 1]: = INTSTR (Integer (buffer [i]) ); End; fient freemem (buffer); end; end ; End; ## fileopen, Fileseek, FileRead Example --------------------------------------- -------------------------------------- FileWrite Write the Archive -------- -------------------------------------------------- ----------------- Unit sysutils function prototype Function FileWrite (Handle: Integer; const buffer; count: integer): integer; example procorm1.button1click (sender: Tobject) VAR backupname: string; FileHandle: integer; stringlen: integer; x: integer; y: integer
begin if SaveDialog1.Execute then begin if FileExists (SaveDialog1.FileName) then begin BackupName: = ExtractFileName (SaveDialog1.FileName); BackupName: = ChangeFileExt (BackupName, '.BAK'); if not RenameFile (SaveDialog1.FileName, BackupName) then raise Exception.Create ( 'Unable to create backup file.'); end; FileHandle: = FileCreate (SaveDialog1.FileName); {Write out the number of rows and columns in the grid.} FileWrite (FileHandle, StringGrid1.ColCount, SizeOf (StringGrid1.ColCount)); FileWrite (FileHandle, StringGrid1.RowCount, SizeOf (StringGrid1.RowCount)); for X: = 0 to StringGrid1.ColCount do begin for Y: = 0 to StringGrid1.RowCount do begin {Write out the length Of e ach string, followed by the string itself} StringLen:. = Length (StringGrid1.Cells [X, Y]); FileWrite (FileHandle, StringLen, SizeOf (StringLen)); FileWrite (FileHandle, StringGrid1.Cells [X, Y], Length (stringgrid1.cells [x, y]); // ????????? / end; end; fileHandle; end;
## FileExists, Renamefile, FileCreate, FileWrite, FileClose, ExtractFileName Example ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------- Fileseek mobile archive indicator location ---- -------------------------------------------------- ----------------------- Unit sysutils function prototype Function Fileseek (Handle, Offset, Origin: Integer): Integer; Description Origin = 0 Read / write indicator The beginning of the file is counted. Origin = 1 read / write indicator is calculated from the current position. Origin = 2 read / write indicators move to the end of the file. **** Features is the same as the DOS INT 21h interrupted 42h. Failure -1 example procedure TForm1.Button1Click (Sender: TObject); var FileHandle:. Integer; FileName: String; Buffer: PChar; S: String; ReadBytes: Integer; begin FileName: = 'c: /delphi_test/abc.ttt'; S: = '1234567890'; if FileExists (filename) THEN FileHandle: = FileOpen (FileName, Fmopenreadwrite) else filehandle: = filecreate (filename); if FileHandle <0 The begin Messagedlg ('Opening Failed', Mtinformation, [Mbok], 0); EXIT;
GetMem (Buffer, 100); Try Strpcopy (Buffer, S); FileWrite (FileHandle, Buffer ^, 10); Fileseek (FileHandle, 4, 0); ReadBytes: = FileRead (FileHandle, Buffer ^, 100); buffer [Readbytes ]: = # 0; label1.caption: = INTOSTR (READBYTES) '' STRPAS (Buffer); Finally FreeMem (Buffer); end; fileHandle (FileHandle);
Results After Archive, Abc.ttt has a total of ten bytes, etc. from the fifth bit, and the six digits are started. 567890 (displacement is starting from 0)
Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT);
var iFileHandle: Integer; iFileLength: Integer; iBytesRead: Integer; Buffer: PChar; i: Integer begin if OpenDialog1.Execute then begin try iFileHandle: = FileOpen (OpenDialog1.FileName, fmOpenRead); iFileLength: = FileSeek (iFileHandle, 0,2 Fileseek (ifilehandle, 0); buffer: = pchar (instocmelength 1)); ibytesread = fileread (ifilehandle, buffer, ifilength); FileClose (ifilehandle); for i: = 0 to ibytesread-1 do Begin stringgrid1.rowcount: = stringgrid1.rowcount 1; stringgrid1.cells [1, i 1]: = buffer [i]; stringgrid1.cells [2, i 1]: = INTSTR (Integer (buffer [i]) ); End; fient freemem (buffer); end; end ; End; ## fileopen, Fileseek, FileRead Example --------------------------------------- -------------------------------------- Filegetttr Archive Properties --------- -------------------------------------------------- ------------------ Unit SysUtils function prototype function FileGetAttr (const FileName: string): Integer; Description faReadOnly = $ 00000001; faHidden = $ 00000002; faSysFile = $ 00000004; faVolumeID = $ 00000008; Fadirectory = $ 00000010; Faarchive = 00000020; FaanyFile = $ 0000003F;
Sample Procedure TFORM1.BUTTON1CLICK (Sender: Tobject); var s: string; begin s: = INTTOSTR (Filegetttr ('c: /delphi_d/delphi_help1.txt')); label1.caption: = s; end; ------ -------------------------------------------------- ----------------------- FileSetattr Settings File Properties ---------------------- -------------------------------------------------- ----- Unit Sysutils Function Prototype Function FileSetattr (Const FileName: String; Attr: Integer: Integer; Description Settings success back 0 ------------------- -------------------------------------------------- -------- FindClose end Findfirst / Findnext ------------------------------------ ---------------------------------------- Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); Var Sr: tsearchrec; factory; begin stringgrid1.rowc ount: = 1; if CheckBox1.Checked then FileAttrs: = faReadOnly else FileAttrs: = 0; if CheckBox2.Checked then FileAttrs: = FileAttrs faHidden; if CheckBox3.Checked then FileAttrs: = FileAttrs faSysFile; if CheckBox4.Checked then FileAttrs : = FileAtTRS FAVOLUMEID; if Checkbox5.checked THEN
FileAtTRS: = FileAtTRS Fadirectory; if Checkbox6.checked the fileattrs: = FileAtTRS Faarchive; if CheckBox7.checked the
FileAtTRS: = FileAtTRS FAANYFILE;
IF FindFirst (Edit1.Text, FileAttrs, SR) = 0 THENBEGIN with STRINGGRID1 Do Begin IF (sr.attr And Fileattrs) = sr.attr Then Begin Cells [1, RowCount-1]: = Sr.Name; Cells [2, Rowcount-1]: = INTTOSTR (Sr.Size); end; while FindNext (sr) = 0 Do Begin if (sr.attr and fileattrs) = sr.attr the beginning; cells [1, Rowcount -1]: = Sr.Name;
Cells [2, ROWCOUNT-1]: = INTOSTR (sr.size); end; end; findclose (sr); end; end; end; ## findfirst, findnext, findclose example ------------ -------------------------------------------------- ----------------- Findfirst Looking for the first unit. ------------------------ -------------------------------------------------- --- Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT);
var sr: TSearchRec; FileAttrs: Integer; begin StringGrid1.RowCount: = 1; if CheckBox1.Checked then FileAttrs: = faReadOnly else FileAttrs: = 0; if CheckBox2.Checked then FileAttrs: = FileAttrs faHidden; if CheckBox3.Checked then FileAttrs : = FileAtTRS FASYSFILE; if CheckBox4.checked The fileattrs: = FileAtTRS FAVOLUMEID; if Checkbox5.checked THEN
FileAtTRS: = FileAtTRS Fadirectory; if Checkbox6.checked the fileattrs: = fileattrs faarchive; if checkbox7.checked thenfileattrs: = FileAtTRS FAANYFILE
IF FindFirst (Edit1.Text, FileAtTRS, SR) = 0 THEN
Begin with stringgrid1 do begin if (sr.attr and fileattrs) = sr.attr The begin Cells [1, RowCount-1]: = sr.name; Cells [2, RowCount-1]: = INTOSTR (sr.size); End; while FindNext (SR) = 0 do begin if (sr.attr and fileattrs) = sr.attr The begin rowcount: = rowcount 1; cells [1, rowcount-1]: = sr.name; Cells [2, RowCount-1]: = INTTOSTR (sr.size); end; end; findclose (sr); end; end; end; ## findfirst, findnext, findclose example -------------- -------------------------------------------------- ------------- Findnext looks for the next matching file. ----------------------------- ---------------------------------- - Unit SysUtils 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; Description successfully pass聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽' INTSTOSTR (SREC.Size) ' Bytes in size '; end; procedure tform1.againclick (sender: TOBJECT);
Begin FindNext (SREC); label1.caption: = SREC.NAME 'IS' INTOSTR (SREC.SIZE) 'BYTES in size'; end; procedure tform1.formclose (Sender: TOBJECT); Begin FindClose (SREC); EndtsearchRec = Record Time: Integer; attr: Integer; Name: TFileName; XCludeAttr: Integer; FindHandle: THANDDATA: Twin32Finddata;
===================================================== floating-point conversion routines float Point conversion function ========================================================================================================================================================================================================================================================= The floating point number is converted to decimers. -------------------------------------------------------------------------------------------------------------------- ---------------------------------- Unit sysutils function prototype Procedure Floattodecimal (Var Result: TfloatRec; Const Value; ValueType: TfloatValue; Precision, Decimals: Integer; --------------------------------------- ------------------------------------ FLOATTOSTRF converts floating point numbers to formatted strings. -------------------------------------------------- -------------------------- Unit sysutils function prototype Function floattostrf (value: extended; format: tfloatformat; precision, Digits: integer): string; -------------------------------------------------- -------------------------- FLOATTOSTR converts floating point numbers into strings. -------------- ------------------------- -------------------------------------- Unit sysutils function prototype Function FLOATTOSTR (Value: Extended): String;
-------------------------------------------------- -------------------------- FLOATTETEXT converts floating point numbers to formatted ten into the place. ------------ -------------------------------------------------- --------------- Unit sysutils function prototype Function floattotext (Buffer: pchar; const value; value; tfloat; precision, digits: integer: integer; ---- -------------------------------------------------- ---------------------- FLOATTEXTFMT converts floating point numbers to formatted ten into the place. ---------------- -------------------------------------------------- --------- Unit sysutils function prototype Function FloattotextFMT (Buffer: Pchar; Const Value; ValueType: Tfloatue; Format: Pchar): Integer; -------------- -------------------------------------------------- ------------- FormatFloat converts floating point numbers to formatted strings. -------------------------- ---------------------------------------------- ---- Unit Sysutils Function Prototype Function Formatfloat (const format: string; value: extended): string; -------------------------------------------------------------------------------------------------------------------- -------------------------------------------------- - STRTOFLOAT converts strings to floating point numbers. -------------------------------------------------------- ------------------------------------- Unit sysutils function prototype Function Strtofloat (const s: string): Extended; example procedure tform1.button1click (sender: Tobject); var value: double; s: string; begin s: = '1234.56'; value: = straoploat (s); label1.caption: = Format ('
Convert [% 9.3F] ', [Value]); END; Note If the S are string contains non-digital characters, an error signal will occur. ------------------ -------------------------------------------------- -------- TextTOFLOAT converts the null-terminated string to floating point numbers. ----------------------------- ---------------------------------------------- Unit sysutils Function prototype Function TEXTTTOFLOAT (BUFFER: PCHAR; VARUE; VALUETYPE: TFLOATVALUE): Boolean;
==========================================================, Flow-Control Routines process control ==================================================== Break from For, While, Or review is terminated. -------------------------------------------- ------------------------------- Unit System Function prototype procedure break; example var s: string; begin while true do begin Readln (s); Try if s = 'TEN BREAK; Writeln (s); Finally {Do Something for All Cases} End; End; ------------------------------------------------------------------------------------------ -------------------------------------------------- -------- Continue continues from For, While, or Repeat, -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- Unit system function Prototype Procedure Continue; Example VAR f: file; i: integer; begin for i: = 0 to (filelistbox1.items.count - 1) do begin tryexists (fileElistbox1.items.strings " ) The 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 (filesis (f))); Closefile (f); end; finally {do something heren} end; end; end; example 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 heren} end; end; end; ## Continue, items, SELECTED EXAMPLE - -------------------------------------------------- -------------------------------------------- -------------------------------------------------- ------- Unit System Function prototype procedure exit; ---------------------------------- ------------------------------------------ HALT end program return work system. -------------------------------------------------- -------------------------- Unit System Function Prototype Procedure Halt [(EXITCODE: Integer)]; Example Begin if 1 = 1 THEN Begin IF 2 = 2 Then Begin IF 3 = 3 THEN Begin Halt (1); {Halt Right Here!} end; end; end; canvas.textout (10, 10, 'this will not be el); end; ------------- -------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------- - Unit System Function Prototype Procedure RuNerror [(ERRORCODE: BYTE)]; Sample Begin {$ IFDEF Debug} if P = NIL THEN RUNERROR (204); {$ ENDIF} END;
===================================== i / o routines I / O Circular ==== ========================================== assignfile specifies the file to a file variable. --------- -------------------------------------------------- ----------------- Unit System Function Prototype Procedure AssignFile (VAR F; FileName: String); Description ** One file cannot be repeatedly executed more than two times. Example var f: TextFile; S: string; begin if OpenDialog1.Execute then {Display Open dialog box} begin AssignFile (F, OpenDialog1.FileName); {File selected in dialog box} Reset (F); Readln (F, S); {Read the First line out of the file} Edit1.text: = S; {PUT STRING IN A TEDIT Control} Closefile (f); end; end; ## assignfile, OpenDi Alog, Readln, Closefile Example -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------- Closefile close the file. ------------- -------------------------------------------------- -------------- Unit System Function Prototype Procedure Closefile (VAR F);
#### Assignfile, OpenDialog, Readln, CloseFile Example ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --------------------------------------- iResult Retrieving the latest I / O function, Is there a mistake. ---------------------------------------------- ------------------------------ Unit System function prototype Function ioreSult: integer; example var f: file of byte; s: String; begin s: = 'c: /ka/aaa.txt'; assignfile (f, s); {$ I-} reset (f); {$ i } if ioresult = 0 THEN Label1.caption: = 'File SIZE IN BYTES: ' INTOSTR (FileSize (f); Else Label1.caption: =' Opening Failed '; END; Description Recurns 0 indicates no error. Example var f: file of byte; begin if OpenDialog1.execute1 Begin AssignFile (f, openDialog1.filename); {$ I-} reset (f); {$ I } if ioresult = 0 Then Messagedlg ('File Size In Bytes:' INTOSTR (FileSize (f)), Mtinformation, [Mbok], 0) Else Messagedlg ('File Access error ', MTWARNING, [Mbok], 0); end; end; --------------------------------------------------------------------------------------------- ------------------------------------------ Reset starts a available Read the file. --------------------------------------------- ------------------------------- Unit System Function Prototype Procedure Reset (VAR F [: File; RecSize: Word]) ;
-------------------------------------------------- -------------------------- ReWrite builds a new file available. ------------ -------------------------------------------------- --------------- Unit System Function Prototype Procedure Rewrite (VAR F: File [; RecSize: Word]); Sample Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); var f: textfile; I1, I2, I3: Integer; S1, S2, S3: String; Begin I1: = 1234; I2: = 5678; I3: = 90; S1: = 'Abcd'; S2: = 'EFGH'; S3: = ' Ij '; assignfile (f,' c: /ka/aaa.txt '); REWRITE (F); Write (f, i1); Write (f, i2); Write (f, i3); Write (f, s1 Write (f, s2); Write (f, s3); Write (f, I1, i2, i3); Write (f, s1, s2, s3); Writeln (f, i1); Writeln (F, I2); Writeln (F, I3); Writeln (f, s1); Writeln (f, s2); Writeln (f, s3); Writeln (F, I1, I2, I3); Writeln (f, S1, S2, S3); Reset (f); Readln (f, s1); Readln (f, i1); label1.caption: = S1 '' INTOSTR (I1); Closefile (f); end;
Results 1234567890abcdefghij1234567890abcdefghij1234 .. 5678 .. 90 .. Abcd .. Efgh .. ij .. 1234567890.. Abcdefghij .. abcdefghij ..
The above is the archive result, two representative # 13 # 10, two bits. Archiflower with Writeln, multiple wrap symbols # 13 # 10. And if WriteLn (F, I1, I2, I3) will be the same string column There is no interval symbol between variables, causing READ that does not have an expected effect. Read results S1 = 1234567890ABCDefghij1234567890abdefghij1234 length 44 and not # 13 # 10 two bits. I1 = 5678
** Write (f, i1: 10: 2, i2: 8: 2); has a formatted function, like STR.
Sample Procedure TFORM1.BUTTON1CLICK (Sender: Tobject); VAR f: file of byte; i1, i2, i3: byte; recomgin i1: = 16; i2: = 32; i3: = 48; assignfile (f, 'C: / Ka / aaa.txt '); REWRITE (F); Write (f, i1); Write (f, i2); Write (f, i3); Write (f, i1, i2, i3);
I1: = 0; reset (f); read (f, i1);
Label1.caption: = INTTOSTR (I1); Closefile (f); end;
Result File Of Byte and File of Record can only write and read with Write and Read, and cannot be written.
Sample Procedure TFORM1.BUTTON1CLICK (Sender: Tobject); type pprec = record pp_no: string [5]; pp_name: string [10]; pp_age: integer; pp_sum: double; end; var r: pPREC; REC2: pPREC; f: File of pprec; begin with recrecre pp_no: = '0001'; PP_NAME: = 'ABC'; pp_age: = 12; pp_sum: = 600;
AssignFile (f, 'c: /ka/aaa.txt'); REWRITE (F); Write (f, REC);
REC.pp_no: = '0002'; Rec.pp_sum: = 58.2; Write (f, REC); Rec.pp_no: = '0003'; Rec.pp_sum: = 258.242; Write (f, rec);
Seek (f, 1); Read (f, REC2);
Seek (f, 1); truncate (f); {delete, leaving only 0}
Canvas.TextOut (5, 10, REC2.pp_no); Canvas.Textout (5, 30, REC2.pp_name); Canvas.Textout (5, 50, Format ('% d', [REC2.pp_age]); Canvas .Textout (5, 70, Format ('% f', [REC2.pp_sum]);
Closefile (f);
Results PP_NO Deposit 6 BYTES PP_NAME Deposit 11 Bytes PP_age Deposit 4 Bytes (Integer 4 Bytes) PP_SUM Deposit 8 Bytes (Double 8 Bytes)
The entire Record is archived in 16 multiples. EXAMPLE VAR F: TextFile; Begin AssignFile (F, 'Newfile. $$$ "; REWRITE (F); Writeln (f,' Just Created File with this text in it ..." ); Closefile (f); end; ----------------------------------------- ------------------------------------ SEEK mobile archive indicator. --------- -------------------------------------------------- ----------------- Unit System Function Prototype Procedure Seek (VAR F; N: Longint); Description Seek starts from 0. EXAMPLE VAR F: File of Byte; Size: Longint ; S: string; y: integer; begin if OpenDialog1.execute dam assignfile (f, openDialog1.filename); reset (f); size: = filesize (f); s: = 'file size in bytes:' INTOSTR (size); y: = 10; Canvas.TextOut (5, y, s); y: = y canvas.textheight (s) 5; s: = 'seeking halfway inTo file ...'; canvas.textout (5, y, s); y : = y canvas.textheight (s) 5; Seek (f, size div 2); s: = 'Position is now' INTOSTR (FilePos (f)); canvas.textout (5, y, s); Closefile (f); end;
## FileSize, Seek, Filepos Example ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ---------------------------------- Truncate all deletes all the files after the current archive indicator location. - -------------------------------------------------- ------------------------- Unit system function prototype Procedure Truncate (var f); example VARF: FILE OF INTEGER; I, J: Integer; Begin AssignFile (f, 'test.int'); REWRITE (F); for i: = 1 to 6 do Write (f, i); Writeln ('file before truncation:'); reset (f); while not eof f) DO Begin Read (F, I); Writeln (I); End; Reset (f); for i: = 1 to 3 do read (f, j); {read ahead 3 records}}; { Cut file off here}
Writeln; Writeln ('file after truncation:'); reset (f); While Not Eof (f) Do Begin READ (F, I); Writeln (I); End; Closefile (f); ERASE (f); end ; ------------------------------------------------- --------------------------- FilePOS back to the current position of the current file. -------------- -------------------------------------------------- ------------- Unit System Function Prototype Function Filepos (VAR f): longint Description F Can't for TEXT FILE Power: FilePos (f): = 0; Runa: EOF (f): = True; example var f: file of byte; s: string; begin s: = 'c: /ka/abc.txt'; AssignFile (f, s); reset (f); seek (f, 1); label1 .Caption: = 'Current position:' INTOSTR (FilePos (f)); End; Example VA R f: file of byte; s: string; y: integer; begin if opendialog1.execute dam assignfile (f, opendialog1.filename); reset (f); size: = filesis (f); s: = 'File Size in Bytes:' INTOSTR (SIZE); Y: = 10; Canvas.Textout (5, Y, S); Y: = Y Canvas.TextHeight (s) 5; s: = 'Seeking Halfway INTO FILE ... '; canvas.textout (5, y, s);
Y: = y canvas.textheight (s) 5; seek (f, size div 2); s: = 'position is now' INTOSTR (FilePos (f)); Canvas.TextOut (5, Y, S) Closefile (f); end; end; ## filesis, seek, filepos example ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- FileSize file length. -------------------------------------------------- -------------------------- Unit System Function Prototype Function FileSize (var f): Integer; Description f If file If f is Record file If you return the number of record, otherwise you will return the number of BYTE. ## FileSize, Seek, Filepos Example ----------------------------- ---------------------------------------------- EOF test Whether the file ends. ---------------------------------------------- ----------------------------- Unit system function prototype Function EOF (var f): boolean; Function prototype FUNCTION EOF [(VAR F: Text)]: Boolean; Example Var F1, F2: TextFile; CH: char; begin if OpenDialog1.execute1 Begin AssignFile (F1, OpenDialog1.FileName); reset (f1); if Savedialog1 .Execute1.filename; ReWrite (F2); While Not Eof (f1) DO Begin Read (F1, CH); Write (F2, CH); End; Closefile (F2); end; Closefile (F1); end;
Example varF1, F2: TextFile; Ch: Char; begin if OpenDialog1.Execute then begin AssignFile (F1, OpenDialog1.Filename); Reset (F1); if SaveDialog1.Execute then begin AssignFile (F2, SaveDialog1.Filename); Rewrite (F2 ); While not EOF (F1) DO Begin Read (F1, CH); Write (F2, CH); end; CloseFile (F2); end; closefile (f1); end; end; -------- -------------------------------------------------- ------------------ OpenPictureDialog OpenDialog opens the file. -------------------------- -------------------------------------------------- - //savepicturedialog1.defaultExt: = graphiceXtension (Tbitmap); //savePictureDialog1.filter: = graphicfilter (tbitmap);
procedure TForm1.Button1Click (Sender: TObject); var Done: Boolean; begin OpenPictureDialog1.DefaultExt: = GraphicExtension (TIcon); OpenPictureDialog1.FileName: = GraphicFileMask (TIcon); OpenPictureDialog1.Filter: = GraphicFilter (TIcon); OpenPictureDialog1.Options: = [Offilemustexist, OfnochangeReadonly, OFNOCHANGEDIR]; While Not Done Do Begin if OpenPictureDialog1.execute1 Begin if Not (Offerent In OpenPictureDialog1.Options) THEN
begin Application.Icon.LoadFromFile (OpenPictureDialog1.FileName); Done: = True; end else OpenPictureDialog1.Options: = OpenPictureDialog1.Options - ofExtensionDifferent; end else {User cancelled} Done: = True; end; end; ## Eof, Read , Write Example ----------------------------------------------- ----------------------------- Erase deletes files. ---------------- -------------------------------------------------- ---------- Unit System Function Prototype Procedure Erase (VAR F); Detecting You can do it first. Example procedure tform1.button1click (sender: TOBJECT); var f: textfile; begin OpenDialog1 .Title: = 'delete file'; if OpenDialog1.execute1 Begin Assignfile (f, OpenDialog1.file Name); try reset (f); if Messagedlg ('Erase' Opendialog1.FileName '?', MTConfirmation, [mbyes, mbno], 0) = MRYES The Begin Closefile (f); ERASE (f); Except ON EinouTerror Do Messagedlg ('File I / O Error.', MTERROR, [Mbok], 0); End; End; End; Example Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT);
var F: Textfile; begin OpenDialog1.Title: = 'Delete File'; if OpenDialog1.Execute then begin AssignFile (F, OpenDialog1.FileName); try Reset (F); if MessageDlg ( 'Erase' OpenDialog1.FileName '? ', MTConfirmation, [mbyes, mbno], 0) = MRYES THEN BEGIN Closefile (f); ERASE (f); End; Except ON EinouTerror DO
Messagedlg ('File I / O Error.', MTERROR, [Mbok], 0); end; end; end; ## Erase, OpenDialog.Title, OpenDialog.FileName Example ------------ -------------------------------------------------- --------------- rename Change the name. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- Unit system function Prototype Procedure Rename (var f; newname); paragrace Uses Dialogs; var f: File; begin openDialog1.title: = 'choose a file ...'; if OpenDialog1.execute1 begin Savedialog1.Title: = 'reename to .. . '; If Savedialog1.execute1 Begin Assignfile (f, OpenDialog1.FileName); Canvas.Textout (5, 10,' Renaming ' OpenDialog1.FileName ' To ' Savedialog1.FileName); Rename (f, savedialog1.filename); end; end; end; example buy dialogs; var
F: File; Begin Opendialog1.title: = 'Choose a file ...'; if OpenDialog1.execute1 Begin Savedialog1.title: = 'RENAME TO ...'; if Savedialog1.execute The begin AssignFile (f, OpenDialog1. Filename); Canvas.Textout (5, 10, 'Renaming' Opendialog1.FileName 'to' Savedialog1.FileName); Rename (f, Savedialog1.FileName); end; end; end; ------- -------------------------------------------------- ------------------ Getdir passed the directory of the specified disk. -------------------- -------------------------------------------------- ----- Unit System Function Prototype Procedure getDir (d: byte; var s: string); Description D 0 = Current drive, 1 = A disk machine, 2 = B disk machine .... ** This file does not check the disk machine error. Example Var S: string; begin Getdir (0, s); {0 = current drive} messagedlg ('Current Drive and Directory:' S, Mtinformation, [Mbok], 0); END; -------------- -------------------------------------------------- ------------- MKDIR builds a subdirectory. -------------------------------- ------------------------------------------- Unit system function prototype Procedure Mkdir (S: String); Sample Uses Dialogs; Begin {$ I-} {Get Directory Name from Tedit Control} Mkdir (Edit1.Text); if ioresult <>
0 Then Messagedlg ('Cannot Create Directory', MtWarning, [Mbok], 0) Else Messagedlg ('New Directory Created ", Mtinformation, [Mbok], 0); End; ------------ -------------------------------------------------- -------------- RMDir deletes an empty subdirectory. --------------------------- -------------------------------------------------- Unit System function prototype procedure RmDir (S: string); example uses Dialogs; begin {$ I-} {Get directory name from TEdit control} RmDir (Edit1.Text); if IOResult <> 0 then MessageDlg ( 'Can not remove directory' , MTWARNING, [Mbok], 0) Else Messagedlg ('Directory Removed', Mtinformation, [Mbok], 0); End; ---------------------- ------------------------------- ------------------------ CHDIR changes current catalog. --------------------- -------------------------------------------------- ---- Unit System Function Prototype Procedure Chdir (S: String); Example Begin {$ I-} {Change To Directory Specified in Edit1} Chdir (Edit1.Text); if ioresult <> 0 Then Messagedlg ('Cannot " Find Directory ', MTWARNING, [MBOK], 0);
======================================================Mory-management routines Memory management typography ============================================= = Allocmem Configuration Memory. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------- Unit sysutils function prototype Function Allocmem (size: cardinal): Pointer; Description FreeMem Release Memory. ----------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------- ------------------- Unit System Function prototype Function GetHeapStatus: theapstatus; ---------------------------------------------------------------------------------- -------------------------------------------------- ----- GetMemoryManager passed back to the Current HEAP area's memory configuration of memory configuration. ------------------- -------------------------------------------- Unit system function prototype Procedure getMemoryManager (Var Memmgr) TMEMORYMANAGER; EXAMPLE VARGETMEMCOUNT: Integer; FreeMemcount: Integer; ReallocMemcount: Integer; Oldmemmgr: TMemoryManager;
Function newgetMem (size: integer): Pointer; Begin INC; Result: = OldMemgr.getMem (size);
Function NewFreeMem (P: Pointer): Integer; Begin INC (FreeMemcount); Result: = OldMemgr.FreeMem (p); end; function newReallocMem (p: Pointer; SIZE: Integer): Pointer; Begin
INC (ReallocMemcount); Result: = OldMemmgr.ReallocMem (p, size);
Const newmemmgr: tmemoryManager = (getMem: NewgetMem; FreeMem: NewFreeMem; ReallocMem: NewReallocMem);
Procedure setnewmemmgr; begin getMemoryManager (OldMemMgr); setMemoryManager (newMemmgr); end; ## getMemoryManager, setMemoryManager Example ------------------------------------------------------------ ------------------------------------------------- Reallocmem Reconfigure the memory. --------------------------------------------- ------------------------------- Unit Systems Function prototype Procedure ReallocMem (var P: Pointer; SIZE: Integer); -------------------------------------------------- ------------------------- SetMemoryManager Sets the entry point of the memory configuration of the Heap area. ---------- -------------------------------------------------- ----------------- Unit System Function Prototype Procedure SetMemoryManager (Const Memmgr: TmemoryManager);
type THeapStatus = record TotalAddrSpace: Cardinal; s TotalUncommitted: Cardinal; TotalCommitted: Cardinal; TotalAllocated: Cardinal; TotalFree: Cardinal; FreeSmall: Cardinal; FreeBig: Cardinal; Unused: Cardinal; Overhead: Cardinal; HeapErrorCode: Cardinal; end; type PMemoryManager = ^ TMemoryManager; TMemoryManager = record GetMem: function (Size: Integer): Pointer; FreeMem: function (P: Pointer): Integer; ReallocMem: function (P: Pointer; Size: Integer): Pointer; end; Example var
GetMemcount: Integer; FreeMemcount: Integer; ReallocMemcount: Integer; Oldmemmgr: TMemoryManager;
Function newgetMem (size: integer): Pointer; Begin INC; Result: = OldMemgr.getMem (size);
Function NewFreeMem (P: Pointer): Integer; Begin INC (FreeMemcount); Result: = OldMemgr.FreeMem (p);
Function NewReallocMem (P: Pointer; SIZE: Integer): Pointer; Begin
INC (ReallocMemcount); Result: = OldMemmgr.ReallocMem (p, size);
Const newmemmgr: tmemoryManager = (getMem: NewgetMem; FreeMem: NewFreeMem; ReallocMem: NewReallocMem);
Procedure setnewmemmgr; begin getMemoryManager (OldMemMgr); setMemoryManager (newMemmgr); end; ## getMemoryManager, setMemoryManager example ============================ ========== miscellaneous routines Other current =================================== === Exclude Deletes an element in a set of elements ------------------------------------- --------------------------------------- Unit System Function Prototype Procedure Exclude (var s: Set of t; i: t); Describe the I element in the deletion of S --------------------------------- --------------------------------------------------------- -------------------------------------------------- -------------------------- Unit System Function prototype procedure Fillchar (VAR X; Count: Integer; Value); Description Fill in x COUNT.
Example EXAMPLE VAR S: ARRAY [0..79] of char; begin {set to all spaces} Fillchar (s, sizeof (s), ord ('')); Messagedlg (S, Mtinformation, [Mbok], 0) ; END; ----------------------------------------------- ---------------------------- Hi back the high-level number. ------------- -------------------------------------------------- -------------- Unit System Function Prototype Function Hi (x): Byte; Example Var B: Byte; Begin B: = Hi ($ 1234); {$ 12} end; ---- -------------------------------------------------- ----------------------- Include joins an element to a set of elements. ------------------ -------------------------------------------------- ------- Unit System Function Prototype Procedure Include (Var S: Set of T; i: T); Description Add I element to s. -------------- ------------------------------------------------- --------------------------------------------------------------------------------------------------------------------- ---------------------------------------------- Unit System Function prototype Function LO (X): byte; example; begin B: = LO ($ 1234); {$ 34} End; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------- ------- Move from the source variable copy n Bytes to the purpose variable. ------------------------------- -------------------------------------------- Unit system function prototype Procedure move (var source, dest; count: integer); sample var A: Array [1..4] of char; b: integer;
Begin Move (A, B, SIZEOF (B)); {SizeOf = Safety!} end; ----------------------------- ------------------------------------------------ Paramcount directly The number of incoming variables is added after the execution gear. (Arj.exe a Dr.arj D: *. *) ------------------------ -------------------------------------------------- --- Unit system function prototype Function paramcount: Integer; Description If the above example passes 3 Example Vari: Integer; ListItem: String; Begin for i: = 0 to ibQuery1.Paramcount - 1 Do Begin ListItem: = ListBox1.items [i ]; Case ibQuery1.Params [i] .dattype of ftstring: ibQuery1.Params [i] .sstring: = ListItem; ftsmallint: ibQuery1.params [i] .assmallint: = startdef (ListItem, 0); ftinteger: ibQuery1.Params [I] .asinteger: = strtientdef (ListInInTitem, 0); FTWORD:
Ibquery1.Params [i] .asword: = startdef (ListIn, 0); ftboolean: Begin if ListItem = 'true' Then Ibquery1.Params [i] .asboolean: = true else ibQuery1.Params [i] .asboolean: = FALSE End; ftfloat: ibQuery1.Params [i] .asfloat: = start (ListIt); ftcurrency: ibQuery1.Params [i] .ascurrency: = strtofloat (ListItem); ftbcd:
IbQuery1.params [i] .asbcd: = straopurr (ListItem); ftdate: ibQuery1.Params [i] .ASDATE: = strtodate (ListItem); fttime: ibQuery1.Params [i] .astime: = strtotime (ListItem); ftdatetime : IbQuery1.Params [i] .asdatetime: = strtodatetime (ListItem); End; End; End; ## paramcount, datatype, startdef, asxxx example -------------------------------------------------------------------------------------------------------------- -------------------------------------------------- --------- Paramstr ---------------------------------------------------------------------- ------------------------------------- Unit system function prototype Function Paramstr (Index: Integer): String Description Paramstr (0); the name and full directory of the execution file. (C: /zip/arj.exe) Example VAR i: word; y: integer; begin Y: = 10; for i: = 1 to paramcount Do Begin Canvas.TextOut (5, Y, Paramstr (I)); Y: = Y Canvas.TextHeight (paramstr (i)) 5; end; end; example procedure tform1.formcreate (sender: TOBJECT);
Var i: integer; for i: = 0 to paramcount -1 do begin if lowercs (paramstr (i)) = 'beep' Then Windows.beep (10000, 1000) Else IF (LowerCase) = 'exit 'Ten Application.Terminate; End; End; ## paramcount, paramstr example -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------ random messy ----- -------------------------------------------------- ---------------------- Unit system function prototype Function Random [(RANGE: Integer)]; Description 0 <= x I: integer; begin randomize; for i: = 1 to 50 do begin {write to window at random location (random (width), random (height), 'boo!'); End; end; ## Randomize, Random Example -------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------- SizeOf back the number of bits of X-based number. --------- -------------------------------------------------- ----------------- Unit System Function Prototype Function SizeOf (x): Integer; Example Type CustRec = Record Name: String [30]; Phone: String [14]; END VAR P: ^ CustRec; Begin getmem (p, sizeof (custrec)); Canvas.Textout (10, 10, 'THE SIZE OF THE RECORD IS' INTOSTR (Sizeof (CustRec))); FreeMem (p, sizeof CustRec); Readln; END; -------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------- ------------------- Unit system function prototype Function swap (x); sample var x: word; begin x: = swap ($ 1234); {$ 3412} end; -------------------------------------------------- ------------------------ Upcase converts a word to uppercase letters. -------------- -------------------------------------------------- ------------- Unit System Function Prototype Function Upcase (CH: Char): CHAR; Example Uses Dialogs; var s: string; i: integer; begin {get string from tedit control} s: = edit1.text; for i: = 1 to length (s) do s [i]: = UpCase (s [i ]); MessageDlg ('Here IT IS in All Uppercase:' S, Mtinformation, [Mbok], 0); End; Example Vars: String; I: Integer; Begin Get String from Tedit Control} S: = Edit1. TEXT; for i: = 1 to length (s) do if i mod 2 = 0 THEN S [i]: = Upcase (s [i]); edit1.text: = s; End; =================================================== ord routines sequence current == ================================================ DEC makes the variable decrease. ----- -------------------------------------------------- ---------------------- Unit system function prototype Procedure Dec (var x [; n: longint]); Description DEC (x) ==> x: = X-1; DEC (x, n) ==> x: = xn; example var intvar: integer; longintvar: longint; begin intvar: = 10; longintvar: = 10; DEC (intvar); {Intvar: = intvar - 1} DEC (longintvar, 5); {longintvar: = longintvar - 5} end; ------------------------------- -------------------------------------------- INC makes the variable increase ------------------------------------- --------------------------- Unit System Function Prototype Procedure Inc (VAR X [; N: Longint]); Description INC (x: IN, N) ==> x: = xn; example var intvar: integer; longintvar: longint; begin inc (Intvar); {Intvar: = intvar 1} inc (Longintvar, 5); {longintvar: = longintvar 5} end; -------------------------------------------------- -------------------------- ODD check is odd. ----------------- -------------------------------------------------- ---------- Unit system function prototype Function ODD (x: longint): boolean; Example Begin IF odd (5) Then Can Can Canvas.TextOut (10, 10, '5 IS ODD.') Else Canvas.Textout (10, 10, 'Something IS ODD!'); END; ========== ============================= Pointer and address Routines location constant ============== ==================================================================================================================================================================================================================== -------------------------------------------------- ------------ Unit System Function Prototype Function AddR (X): Pointer; Example Var i: Integer; NodenumBers: array [0 .. 100] of integer; Begin With TreeView1 Do Begin for i: = 0 to items.count - 1 do begin nodenumbers [i]: = CalculateValue (items [i]); items [i] .data: = addr (nodenumber [i]); end; end; end; ---- -------------------------------------------------- --------------- ------ Assigned test indicator variable is nil. ---------------------------------- ----------------------------------------- Unit System Function prototype Function Assigned ( VAR P): boolean; Description When @ p = nil ==> Back FALSE Example Var P: Pointer; Begin P: = NIL; if Assigned (P) Then Writeln (' YOU WON 'THIS'); GetMem (p, 1024); {p valid} FreeMem (p, 1024); {p no longer valid and still not nil} if Assigned (P) Then Writeln ('You'll See THIS '); END ============================================= String-Formatting Routines string format == ========================================= fmtstr format. -------------- -------------------------------------------------- ------------- FMTSTR (Var Strresult: string; const format: string; const args: array s string; -------------------------------------------------- --------------------------- format format (const format: string; const args: array s string: string; ----- -------------------------------------------------- ---------------------- Unit sysutils function prototype Procedure FMTSTR (var Result: string; const format: string; const arggs: array of const); Function Format const format: string; const args: array: const): String; Description% D: Integer% E: Scientific F: Dial Real% G: Real N: Real Number (-D, DDD, DDD.DD ... )% M: money format% P: POINT% S: String% x: HEX example var i: integer; j: double; s: string; t: string; begin t: = format ('% D% 8.2F% s', [i, j, s]); listbox1.item.add (t); end; bubbles eries1.PercentFormat: = '## 0.0 #%'; Example procedure TForm1.Table1AfterDelete (DataSet: TDataSet); begin StatusBar1.SimpleText: = Format ( 'There are now% d records in the table', [DataSet.RecordCount]) ; S: = format ('1-? ??????? ??????? -% D, 2-? -% D, 3-? -% d', [10, 20, 30]) ; Format ('% *. * F', [9, 2, 12345.6789]); Format ('% 9.2f', [12345.6789]); Format ('% 3D,% D,% 0: D,% 2: - 4D,% d ', [1, 2, 3, 4]);' 1, 2, 1, 3, 4 ' ## Afterdelete, Format EXAMPLE ================================================ String-handling routines (Pascal-style) string function ======================================= AnsiCompareStr compare the size of two strings. LANGUAGE DRIVER installed. -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------- AnsicompareText (AnsiCompareText This item is not collimated). ------ -------------------------------------------------- --------------------- Unit sysutils Vars1, S2: String; i: integer; Begin S1: = 'a ????'; s2: = '?????'; i: = compareStr (S1, S2); {i = 0,?.?. S1 = s2} if i = 0 THEN Messagedlg (S1, '=', S2, MTWARNING, [Mbok], 0); Function prototype Function AnsicompareStr (Const S1, S2: String): Integer; Function Prototype Function AnsiiMPareText (Const S1, S2: String): Integer; -------------------- -------------------------------------------------- ------- AnsilowerCase transfers all the strings to lowercase letters. ---------------------------------------------------------------------- -------------------------------------------------- ANSIUPPERCASE turns all strings to uppercase letters. Reputable Language Drive ----------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------- Unit sysutils function prototype Function AnsilowerCase (Const S: string; function prototype Function AnsiUppercase (const s: string): string; ------------------------------------------------------------------------------------------------------------------------------------------------------ ---------------------------------------------- CompareStr comparison two The size of a string. -------------------------------------------- -------------------------------- COMPARETEXT (COMPARETEXT This item is not collimated). ------ -------------------------------------------------- - ------------------- Unit sysutils Function Prototype Function CompareStr (Const S1, S2: String): Integer; Function Prototype Function Comparext (Const S1, S2: String): INTEGER; example var string1, string2: string; i: integer; begin string1: = 'steve'; string2: = 'steve'; i: = compareStr (string1, string2); {i <0} if i <0 Then Messagedlg ('String1 Var string1, string2: string; I: integer; begin string1: = 'abc'; string2: = 'aaa'; i: = compareStr (string1, string2); {i <0} if i <0 Then Messagedlg ('String1 Procedure TFORM1.ListView1ColumnClick (Sender: Tobject; Column: TListColumn); Begin columntosort: = column.index; (sender as tcustomlistView) .alphasort; The oncompare Event Handler Causes The List View To Sort on The Selected Column: procedure TForm1.ListView1Compare (Sender: TObject; Item1, Item2: TListItem; Data: Integer; var Compare: Integer); var ix: Integer; begin if ColumnToSort = 0 then Compare: = CompareText (Item1.Caption, Item2.Caption) else Begin ix: = columntosort - 1; Compare: = compareText (item1.subitems [ity], item2.subitems [ity]); end; end; ## NColumnClick, alphasort, oncompare, CompareText Example ------------------ -------------------------------------------------- ------------------ CONCAT will add the string. ------------------------ -------------------------------------------------- --- Unit System Function Prototype Function Concat (S1 [, S2, ..., SN]: String): String; Description and S: = S1 S2 S3 ...; Same. Example Var S: String; S: = concat ('abc', 'DEF'); {'Abcde'} END; Var s: string; begin s: = '?? ?????' '???????? ??????'; s: = concat ('?', '??? ? ',' ???????? ?????? '); //? ????? ??????? s: ='? ???? ????? ??? ?????? 'end; -------------------------------------- -------------------------------------- Copy from the mother character string to another string ------------------------------------- --------------------------- Unit System Function Prototype Function Copy (S: String; Index, Count: Integer): String; Description S : String. INDEXD: From the first few positions. COUNT: A total of several people. Example var s: string; begin s: = 'Abcdef'; s: = Copy (S, 2, 3); {'BCD '} End; ---------------- var s: string; begin s: =' ?????? '; s: = COPY (S, 3, 4); // s: = '????' end; --------------- Example procedure TForm1.ComboBox1KeyPress (Sender: TObject; var Key: Char); var Found: boolean; i, SelSt: Integer; TmpStr: string; begin {first, process the keystroke to obtain the current string} {This code requires all items In list to be uppercase} if key in ['a' .. 'z'] THEN DEC (Key, 32); {force Uppercase Only!} with (sender as tcomboBox) do begin selst: = sleelstart; if (key = CHR (VK_BACK)) and (selLength <> 0) THEN TMPSTR: = COPY (Text, 1, SELSTART) COPY (Text, SelLength SELSTART 1, 255) Else if key = chr (vk_back) THEN {SELLENGTH = 0} TMPSTR: = Copy (Text, 1, SELSTART- 1) COPY (Text, SELSTART 1, 255) Else {key in ['a' .. 'z', etc]} Tmpstr: = COPY (Text, 1, SELSTART) Key Copy (Text, SelLength SELSTART 1,255); if tmpstr = 'Then exit; {update selst to the current insertion point} IF (key = chr (vk_back)) and (selst> 0) THEN DEC (SELST) Else if Key <> chr (vk_back) THEN INC (SELST); key: = # 0; {inde selst = 0 dam; {Now TMPSTR IS The Currently Typed String, See IF We can Locate a match} Found: = false; for i: = 1 to items.count do if copy (items [i-1], 1, length (tmpstr)) = tmpstr the beginning: = items [i-1]; {UPDATE TO THE Match That Was Found} ItemIndex: = I-1; Found: = true; Break; End; if Found the String} Begin Selstart: = SELST; SELLENGTH: = Length (Text) -Selst; Else beep; end; end; ----------------------- procedure tcomponeneditor.copy; var AFORMAT: WORD; Adata, APALETTE: THANDLE; Begin with Component As TIMAGE Do Begin Picture.SaveToClipboardFormat (AFORMAT, Adata, Apalette); Clipboard.Setashandle (AFORMAT, Adata); End; End; ## Copy, Chr, Selstart, Sellength Example -------------------------------------------------- -------------------------- DELETE deletes several characters in the string. ------------ -------------------------------------------------- --------------- Unit System Function prototype Procedure delete (var s: string; index, count: integer); Description S: string. INDEXD: From the first few bits Start deleting. Count : The total of several people should be deleted. Example var s: string; begin s: = 'honest abe lincoln'; delete (s, 8, 4); canvas.textout (10, 10, s); {'honest lincoln'} end Var s: string; begin s: = '???????, ??????????! Delete (s, 8, 1); // S: = '??????? ??????????????????!' Messagedlg (S, MTWARNING, [MboK], 0); end; ----- -------------------------------------------------- -------------------- NewStr Configures a new string space to the PString metrics in HEAP. -------------------------------------------------- -------------------------- DISPOSESTR releases a string space PString metrics in HEAP. ----------- -------------------------------------------------- --------------- Unit sysutils function prototype Function News: PString; Function Prototype Procedure DisposeStr (P: Pstring); Description S: String. Pstring: New String indicator. Example VAR P: pstring; s: string; begin s: = 'ask me About blaise'; p: = newstr (s); DisposeStr (P): end; -------------------------------------------------- -------------------------- INSERT Insert a sub-string into another string. ---------- -------------------------------------------------- ----------------- Unit System Function prototype procedure insert (Source: string; var s: string; index: integer); Description Source: Sub string. S: Plugged Master string. INDEXD: Insert from the first few positions. Example Var s: string; begin s: = 'honest lincoln'; Insert ('Abe', S, 8); {'honest Abe lincoln'} end; var s : string; begin s: = '???????????????????????.'; INSERT ('!', s, 8); {s: = ' ???????! ?????? ???????????. '} messagedlg (s, mtwarning, [mbok], 0); end; -------- -------------------------------------------------- ----------------- INTTOHEX will turn int to HEX. ------------------------ - -------------------------------------------------- - Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); VAR i: integer; begin label1.caption: = '; for i: = 1 to length (edit1.text) do begin try Label1.caption: = label1.caption INTTOHEX ( Edit1.text [i], 4) ''; EXCEPT Beep; End; end; EXAM: Edit2.text: = (Strt "------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------ INTTOSTR converts Int to STR. -------------------------------------------------- --------------------------- Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); begin tryl1.caption: = INTOINT (Edit1. TEXT) * STRTOINT (EDIT2.TEXT)); Except ShowMessage ('You Must Specify Integer Values); End; End; ------------------ -------------------------------------------------- --------- Strtoint converts STR to int. -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------ Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); VAR I: Integer; J: Integer; begin i: = start (edit1.text); J: = strt2.text); showMessage (INTTOSTR (i J)); end; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------ STRTOINTDEF Transform Str to int. When the conversion is incorrect, it passes back the value of default. ------------------------------- -------------------------------------------- Unit sysutils 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: Integer to convert. DIGITS: To convert to a few digits of HEX. Example Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); begin edit2.text: = INTTOHEX (atTRTOINT (Edit1.Text), 6); Procedure TForm1.Button1Click (Sender: Tobject); VARUE: Integer; begin value: = 1234; edit1.text: = INTOSTOSTR (VALUE); Procedure TForm1.Button1Click (Sender: Tobject); var s: string; i: integer; begin s: = '22467'; i: = strt (s); inc (i); edit1.text: = INTOSTR (i); END; procedure TForm1.Button1Click (Sender: TObject); var NumberString: string; Number: Integer; begin NumberString: = Edit1.Text; Number: = StrToIntDef (NumberString, 1000); Edit2.Text: = IntToStr (Number); end; Example VAR I: integer; list; for i: = 0 to query1.paramcount - 1 do begin ListItem: = listbox1.items [i]; case query1.params [i] .DataType of ftstring: query1.params [i] .Sstring: = listitem; ftsmallint: query1.Params [i] .assmallint: = startdef (ListInd, 0); ftinteger: query1.params [i] .asinteger: = startdef (ListItem, 0); ftword: query1.params [ I] .asword: = startdef (Listitem, 0); ftboolean: Begin if ListItem = 'true' Then query1.Params [i] .asboolean: = true else query1.params [i] .asboolean: = false; end; ftfloat : Query1.params [i] .asfloat: = start (ListIt (ListIt); FTCURRENCY: Query1.Params [i] .ascurrency: = struploat (listitem); ftbcd: query1.params [i] .asbcd: = straopurr (ListItem); ftdate: Query1.Params [i] .ASDATE: = Strtodate (ListItem); fttime: query1.params [i] .astime: = startIME (ListItem); ftdatetime: query1.params [i] .asdatetime: = stratodatetime (ListItem); END End; end; -------------------------- Procedure TFORM1.BUTTON1CLICK (Sender: Tobject); beg Number: integer; begin number: = STRTOINTDEF (Edit1.Text, 1000); Edit2.Text: = INTOSTOTR (Number); end; ------------------ ## paramcount, datatype, startdef, asxxxxxxxE -------------------------------------------------- -------------------------- STR converts the numerical value into a formatted string. ------------ -------------------------------------------------- --------------- Unit System Function Prototype Procedure Str (x [: width [: Decimals]]; VAR S); Description x: Integer OR implementation of the conversion. Width: Format length. (Integer): Decimal point number. (Integer) Example Function makeitastring (i: longint): string; {Convert Any Integer Type to a string} var s: string [11]; begin Str (i , S); makeitastring: = S; End; Begin Canvas.TextOut (10, 10, makeitastring (-5322)); END; --------------------- -------------------------------------------------- ------ VAL converts the strings into numbers. ------------------------------------ ---------------------------------------- Unit System Function prototype Procedure Val (S; VAR V; VAR code: integer; Description S: String to conversion. V: The integer OR implementation after conversion. Code: code = 0 Indicates the success of the conversion. Example Uses Dialogs; Var I, Code: integer; begin {Get Text from Tedit Control} Val (Edit1.Text, I, Code); {ERROR DURING CONVERSION TO INTEGER?} if code <> 0 Then Messagedlg ('Error At Position:' INTOSTOSTR (CODE), MTWARNING, [MboK], 0); Else Canvas.TextOut (10, 10, 'Value =' INTSTR (I)); Readln; End; ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -------------------------------------------------- - Length string length. -------------------------------------------- ------------------------------- Unit system function prototype Function Length: Integer; Description S: Strings for conversion. Example Var S: String; Begin S: = 'The Black Knight'; Canvas.TextOut (10, 10, 'String Length =' INTOSTR (Length (s))); End; Example Procedure TFORM1.BUTTON1CLICK (Sender: Tobject); var i: integer Begin label1.caption: = '; for i: = 1 to length (edit1.text) do begin tryl1.caption: = label1.caption INTTOHEX (Edit1.Text [i], 4) ' '; Except Beep ; Sample procedure tForm1.button1click (sender: TOBJECT); var s: string; begin s: = memo1.text; label1.caption: = '' INTOSTR (length (s)); end; var s: string; i: integer Begin s: = '? ???? ???????? ??????; i: = length (s); // i: = 22 messagedlg (' ?????? ????? = ' INTOSTR (I), MTWARNING, [Mbok], 0); End; ## ignth, INTTOHEX EXAMPLE ---------------------- -------------------------------------------------- ------ POS Looking for the position of the subrinder in the mother character string. -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- Unit system function Prototype FUNCTION POS (SUBSTR: STRING; S: String): Integer; Substr: Subside string. S: Master Brand. Example Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); var s: string; begin s: = '1234.5 " {Convert Spaces to Zeroes} While POS ('', s)> 0 DO S [POS ('', s)]: = '0'; label1.caption: = S; label1.font.size: = 16; END ; Var s: string; I: integer; begin s: = '? ???? ???????? ??????'; i: = POS ('???', s); / / I: = 3 end; // Demo 001234.50 // Blank word string repair -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------- LowerCase will string all Transfer to lowercase letters. ----------------------------------------------------------------------- ------------------------------ Unit System Function prototype Function LowerCase: String; Example Procedure TFORM1 .Button1Click (Sender: TObject); begin Edit2.Text: = LowerCase (Edit1.Text); end; Example procedure TForm1.Button1Click (Sender: TObject); begin Label1.Caption: = LowerCase (Edit1.Text); end; var S: string; begin s: = Lowercase ('????????. Txt'); // s: = '????????. Txt' end; ------- - -------------------------------------------------- ------------------- Uppercase Transfer all strings to uppercase letters. --------------------- -------------------------------------------------- ---- - Unit sysutils function prototype Function Uppercase: String; Sample Procedure TFORM1.BUTTON1CLICK (Sender: Tobject); Var i: integer; begin for i: = 0 to listbox1.items.count - 1 Do ListBox1.items [I]: = Uppercase (ListBox1.Items [i]); End; Example Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); VAR i: integer; Begin for i: = 0 to listbox1.items.count -1 do listbox1.items [i]: = uppercase (listbox1.items [i]); end; --------------- -------------------------------------------------- ------------ TRIM clears the blank and control character before and after the strings. Trim (const s: string): string; sysutils var s: string; l: integer; begin s: = # 13 '???!' # 13; l: = length (s); // L: = 10 s: = trim (s); // s: = '???!' L: = l-length (S); // L: = 5 messagedlg ('??????? ???????? -' INTOSTR (L), Mtinformation, [MboK], 0); end; -------------------------------------------------- ------------------------ Trimleft clears the blank and control character on the left side of the strings. Sysutils var s: string; l: integer; begin s : = # 13 '???!' # 13; l: = length (s); // L: = 10 s: = TriML EFT (s); // s: = '???!' # 13 l: = l-length (s); // L: = 3 messagedlg ('??????? ?????? ?? - ' INTOSTR (L), Mtinformation, [Mbok], 0); END; ----------------------------- ---------------------------------------------- Trimright The blank and control character on the right side of the strings are clear. -------------------------------------- -------------------------------------- Unit sysutils function prototype Function TRIM (Const S: String : String; Function prototype Function Trimleft (const s: string): String; Function prototype Function Trimright (const s: string): string; Var s: string; l: integer; begin s: = # 13 '???!' # 13; l: = length (s); // L: = 10 s: = trimright (s); // s: = # 13 '???!' L: = l-length (s); // L: = 2 messagedlg ('??????? ???????? -' INTOSTR (L) , Mtinformation, [Mbok], 0); End; ---------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 13 # 10 ----------------------------------------------- ----------------------------- Unit sysutils function prototype Function AdjustLineBreaks (const s: string): string; ================================================ String-handling routines (null-terminated) string Function =================================================================================================================================================================================================================================================================================================== -------------------------------------------------- ------------------------ Unit sysutils function prototype Function Stralloc (size: cardinal): pchar; Description size = string maximum space 1 --- -------------------------------------------------- ------------------------ StrBufsize Replies the size of the STRALLOC configuration space ----------------- -------------------------------------------------- --------- Unit sysutils function prototype Function strbufsize (str: pchar): cardinal; ---------------------------------------------------------------------------------------------------- -------------------------------------------------- - STRCAT string adds. ------------------------------------------- -------------------------------- - Unit sysutils function prototype Function Strcat (DEST, SOURCE: PCHAR): PCHAR; Example USE s sysutils; const Obj: pchar = 'object'; pascal: pchar = 'pascal'; var s: array [0..15] of char; begin strcopy (s, obj); strcat (s, '); strcat (S, pascal); Canvas.TextOut (10, 10, strpas (s)); EXAMPLE Procedure TFORM1.BUTTON1CLICK (Sender: Tobject); var buffer: pchar; begin getmem (buffer, length1.caption) length (edit1.text) 1); strcopy (buffer, pchar (label1.caption); Strcat (buffer, pchar (edit1.text)); label1.caption: = buffer; edit1.clear; freemem (buffer); end; const p0: pchar = '?????? -'; p1: pchar = ' ???????????; p2: pchar = '????????'; var S1, S2: Array [0..20] of char; begin strcopy (S1, P0); Strcopy (S2, P0); STRCAT (S1, P1); {S1: = '?????? - ??????????'} STRCAT (S2, P2); {S2: = ' ?????? - ???????? '} messagedlg (S1 # 13 S2, Mtinformation, [Mbok], 0); ## Strcopy, Strcat Example -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------- Strcomp compare the two string sizes. ---------- -------------------------------------------------- ----------------- Unit Sysutils Function Prototype Function Strcomp (str1, str2: pchar): integer; example Uses sysutils; const S1: pchar = 'WACKY'; S2: PCHAR = 'Code'; var C: integer; result: string; begin c: = strComp (S1, S2); IF c <0 Then Result: = 'is less' else if c> 0 Then Result: =' is Greater Than 'Else Result: =' is equal to '; canvas.textout (10, 10, strPas (S1) Result StrPas (S2)); End; Example Uses sysutils; procedure tform1.button1click (sender: TOBJECT); var MSG : String; Compresult: integer; begin msg: = edit1.text; compresult: = strcomp (pchar (edit1.text), pchar (edit2.text)); if Compresult <0 THEN MSG: = MSG 'Is Less Than' else IF Compresult > 0 THEN MSG: = MSG 'Is Greater Than' Else Msg: = Msg 'Is Equal to' MSG: = MSG Edit2.Text; ShowMessage (MSG); Var S1, S2: PCHAR; I: Integer; Res: string; begin s1: = 'company'; s2: = 'company'; i: = strcomp (S1, S2); if i> 0 Then Res: = '>>> 'Else if i <0 THEN RES: =' <'else res: =' = '; Messagedlg (S1 RES S2, Mtinformation, [Mbok], 0); End; ------------ -------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- Unit sysutils function Prototype Function Strcopy (DEST, SOURCE: PCHAR): PCHAR; example Uses sysutils; var s: array [0..12] of char; begin strcopy (s, 'objectpascal'); Canvas.Textout (10, 10, StrPas S)); End; Example Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); VAR BUFF ER: pchar; begin getmem (buffer, length1.caption) length (edit1.text) 1); strcopy (buffer, pchar (label1.caption)); strcat (buffer, pchar (edit1.text)); Label1.caption: = Buffer; Edit1.clear; FreeMem (Buffer); ## Strcopy, Strcat Example -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------- STRDispose releases the space configured with Stralloc or strnew. ------- -------------------------------------------------- ------------------- Unit sysutils function prototype procedure strdispose (str: pchar); example Uses sysutils; const s: pchar = 'nevermore'; var P: pchar; Begin P: = strnew (s); Canvas.Textout (10, 10, StrPas (P)); strdispose (p); end; -------------------- -------------------------------------------------- ------ Strecopy Copy String and Transfer Strings End Address. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --------------------------------------------- Unit sysutils function Prototype Function Strecopy (DEST, SOURCE: PCHAR): PCHAR; Sample Uses System; Const Turbo: PCH Ar = 'Object'; pascal: pchar = 'pascal'; var s: array [0..15] of char; begin strecopy (strecopy (STRECOPY (S, Turbo), ''), PASCAL); Canvas.Textout 10, 10, StrPas (s)); end; example buys sysutils; const Turbo: Pchar = 'Object'; Pascal: PCHAR = 'PASCAL'; var S: Array [0..15] of char; begin strecopy (strecopy (STRECOPY (S, Turbo), ''), pASCAL); Canvas. Textout (10, 10, string (s)); end; ------------------------------------ ---------------------------------------- Strend Password end address. -------------------------------------------------- -------------------------- Unit sysutils function prototype Function Strend (str: pchar): PCHAR; Sample Uses sysutils; const s: pchar = 'Yankee Doodle'; Begin Canvas.TextOut (5, 10, 'THE STRINGTH OF "' STRPAS (S) '" IS' INTOSTR (STREND (S) - S)); End; Example Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); VAR TEXTBUFFER: PCHAR; PTR: PCHAR; Begin getmem (TextBuffer, L ENGTH (EDIT1.TEXT) 1); strcopy (TextBuffer, Pchar (edit1.text)); ptr: = streven; label1.caption: = '; while ptr> = textBuffer do begin PTR: = PTR? 1 Label1.caption: = label1.caption ptr ^; end; freemem (textBuffer); Var str: Pchar; L: Word; Begin ... l: = streven - str; ... End; ------------------------------------------------------------------------------------------------------------------------------------------------ -------------------------------------------------- ----- StriComp compared the two string sizes. (Regardless of case) ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------- Unit sysutils function prototype Function StriComp (str1, str2: pchar): integer; paragrace Uses sysutils; const S1: pchar = 'WACKY'; S2: PCHAR = 'code'; var C: Integer; Result: string; begin c: = StriComp (S1, S2 ); If c <0 Then Result: = 'is less' Else IF C> 0 Then Result: = 'Is Greater Than' Else Result: = 'Is Equal to'; Canvas.Textout (10, 10, STRPAS (S1 ) Result strPas (S2)); END; Xample Uses sysutils; procedure tform1.button1click (sender: TOBJECT); Var msg: string; compresult: integer; begin msg: = Edit1.Text; Compresult: = stricomp (pchar (edit1.text), pchar (edit2.text)); if Compresult <0 THEN MSG: = MSG 'is Less Than 'Else IF Compresult> 0 THEN MSG: = Msg ' Is Greater Than 'Else Msg: = MSG ' Is Equal to 'MSG: = Msg Edit2.Text; ShowMessage (MSG); Var S1, S2: PCHAR; I: Integer; Res: string; begin S1: = 'ABC'; S2: = 'abc'; i: = stricomp (S1, S2); {i: = 0,?. S1 = S2} if i> 0 THEN RES: = '>' else if i <0 Then Res: = '<' else res: = '='; Messagedlg (S1 RES S2, Mtinformation, [Mbok], 0 ); END; ---------------------------------------------- ----------------------------- Strlcat string is added. (Designation length) --------- -------------------------------------------------- ----------------- Unit sysutils function prototype Function strlcat (dest, source: pchar; maxlen: cardinal): pchar; example uses sysutils; var s: array [0 .. 13] OF Char; Begin Strlcopy (S, 'Object', SizeOf (s) - 1); Strlcat (S, '', SIZEOF (S) - 1); Strlcat (S, 'Pascal', SizeOf (s) - 1); Canvas.TextOut (10, 10, StrPas (s)); End; Example Procedure TFORM1.BUTTON1CLICK (Sender: Tobject); var firsthalf: pchar; secondhalf: pchar; halflen: integer; begin halflen: = strlen (pchar (pchar) TEXT)) Div 2; getMem (Firsthalf, Halflen 2); getMem (Secondhalf, Halflen 2); firsthalf ^: = chr (0); secondhalf ^: = CHR (0); strlcat (first1. TEXT), HALFLEN; STRCAT (Secondhalf, Pchar (Edit1.Text) Halflen; Application.MessageBox (Firsthalf, 'First Half', MB_OK); Application.MessageBox (Secondhalf, 'Second Half', MB_OK); FreeMem (Firsthalf); FreeMem (Secondhalf); Const S1: PCHAR = '???'; s2: pchar = '?????????'; var s: array [0..13] of char; becom strlcopy (S, S1, Strlen (S1 )); Strlcat (s, s2, 6); {s: = '??????'} messagedlg (s, mtinformation, [mbok], 0); end; ## strlen, strlcat example ---- -------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------- ----------- Unit sysutils function prototype Function strlcomp (str1, str2: pchar; maxlen: cardinal): integer; example uses sysutils; const S1: pchar = 'Enterprise' s2: pchar = 'enter' Var Result: String; Begin IF Strlcomp (S1, S2, 5) = 0 THEN RESULT: = 'Equal' Else Result: = 'DIFFERENT'; Canvas.TextOut (10, 10, 'The First Five Characters Are' Result); End; Example Uses System; Const S1: Pchar = 'Enterprise' S2: Pchar = 'Enter' Var COMSTR: String; Begin IF Strlcomp (S1, S2, 5) = 0 THEN COMSTR: = 'Equal' Else Comstr: = 'Different'; Canvas.TextOut (10, 10, 'The First Five Characters Are' COMSTR); END; Const S1: PCHAR = '?????????'; S2: PCHAR = '????????'; Var i: integer; s: string; begin i: = 5; if strlcomp S1, S2, I) = 0 THEN S: = '?????' else s: = '????????'; messagedlg ('?????? INTOSTOSTR (i) '???????? ?????' s, mtinformation, [mbok], 0); end; --------------------- -------------------------------------------------- ------ Strlcopy copy string. (Designation length) ----------------------------------- ----------------------------------------- Unit sysutils function prototype Function Strlcopy (DEST , Source: pchar; maxlen: cardinal: pchar; paragrace Uses sysutils; var s: array [0..11] of char; ber; ber; becom strlcopy (s, 'objectpascal', sizeof (s) - 1); canvas.textout 10, 10, STRPAS (S)); End; Example Uses sysutils; const MAX_BUFFER = 10; procedure TForm1.Button1Click (Sender TObject); var Buffer: array [0..MAX_BUFFER] of char; begin StrLCopy (Buffer, PChar (Edit1.Text), MAX_BUFFER); Application.MessageBox (Buffer, 'StrLCopy EXAMPLE ', MB_OK); Var s: pchar; begin strlcopy (s, '?????????', 5); {s: = '?????'} ... End; ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -------------------------------------------------- ------------------ Strlen passed the length of the string. (Excluding the termination element) ----------------- -------------------------------------------------- --------- Unit sysutils function prototype Function Strlen (str: pchar): cardinal; paragrace Uses sysutils; const s: pchar = 'e pluribus uniform'; Begin Canvas.Textout (5, 10, 'THE String length of "' strPas (s) " IS' INTOSTR (Strlen (s))); End; Example Procedure TFORM1.BUTTON1CLICK (Sender: Tobject); var firsthalf: pchar; secondhalf: pchar; halflen: integer Begin Halflen: = Strlen (pchar (edit1.text)) DIV 2; getMem (Firsthalf, Halflen 2); getMem (Secondhalf, Halflen 2); firsthalf ^: = chr (0); secondhalf ^: = chr (0); strlcat (firsthalf, pchar (edit1.text), halflen; strcat (secondhalf, pchar) Edit1.Text) HalfLen); Application.MessageBox (FirstHalf, 'First Half', MB_OK); Application.MessageBox (SecondHalf, 'Second Half', MB_OK); FreeMem (FirstHalf); FreeMem (SecondHalf); end; Const s: pchar = '????? ?????????? ????????!'; Begin Messagedlg (S # 13 # 10 '???????? ?? ???????? = ' INTOSTR (Strlen (s)), mtinformation, [mbok], 0); End; ## strlcat example ------------ -------------------------------------------------- --------------- Strlicomp compares the two string sizes. (Specify long, regardless of case) ------------------- -------------------------------------------------- ------- Unit sysutils function prototype Function Strlicomp (STR1, STR2: PCHAR; MAXLEN: cardinals): Integer; example uses sysutils; const s2: pchar = 'Enterprise' s2: pchar = 'Enter' Var Result: String; Begin IF Strlicomp (S1, S2, 5) = 0 Then Result: = 'Equal' Else Result: = 'DIFFERENT'; Canvas.Textout (10, 10, 'THE FIRST FIVE C Haracters is' result; end; example: pchar = 'Enterprise' s2: pchar = 'enter' Var Comstr: String; Begin IF Strlicomp (S1, S2, 5) = 0 THEN COMSTR: = 'Equal' Else Comstr: = 'DIFFERENT'; Canvas.TextOut (10, 10, 'The First Five Characters Are' COMSTR) ; Const S1: PCHAR = '?????????'; S2: PCHAR = '????????'; var s: string; Begin IF Strlicomp (S1, S2, 5) = 0 THEN S: = '?????' Else S: = '????????'; MessageDlg (S1 # 13 S2 # 13 "?????? ' INTOSTR (i) '???????? ?????' s, mtinformation, [mbok], 0); end; -------------------- -------------------------------------------------- ------- strlower will turn the string to lowercase letters. --------------------------------- ------------------------------------------ Unit sysutils function prototype Function Strlower (Str: pchar): PCHAR; example Uses sysutils; const s: pchar = 'a funny string' begin canvas.textout (5, 10, strpas (strlower (s)) '' StrPas (Strupper (s)))) ; END; ----------------------------------------------- ------------------------------ Strmove causes the source string to copy n bytes to the climbing R string. (Excluding the termination chamber) ------------------------------------------------------------ ------------------------------------ SysUtils function prototype function StrMove (Dest, Source: PChar; Count: Cardinal): PChar; example uses SysUtils; function AHeapaString (S: PChar): PChar; {Allocate string on heap} var L: Cardinal; P: PChar; begin strNew : = NIL; if (s <> nil) and (s [0] <> # 0) THEN BEGIN L: = Strlen (s) 1; getMem (p, l); strnew: = Strmove (P, S, L); end; end; procedure disposedastring (s: pchar); {Dispose string on head} begin if s> nil Then FreeMem (S, Strlen (S) 1); End; Var S: pChar; Begin Aheapastring (s); DisposedaString (s); end; var s1, s2: pchar; begin s1: = 'abcdefgh'; strmove S2, S1, STRLEN (S1) 1); strlower (S1); {S1: = 'Abcdefgh'} Strupper (S2); {S2: = 'Abcdefgh'} Messagedlg (S1 # 13 # 10 S2, Mtinformation , [Mbok], 0); End; -------------------------------------------------------------------------------------------------------------------------------- ------------------------------------- Strnew Configuration String Space. ------- -------------------------------------------------- ---------------- ---- Unit sysutils function prototype Function strnew (str: pchar): pchar; example uses sysutils; procedure tform1.button1click (sender: TOBJECT); Var Temp: Pchar; Begin // Allocate Memory. Temp: = strnew (Pchar (Edit1.Text)); Application.MessageBox (Temp, 'Strnew, Strdispose Example', MB_OK); // DEAllocate Memory. STRDispose (TEMP); END; Const S: PCHAR = '??????????? ???????; var snew: pchar; begin snew: = strnew (s); messagedlg (' s: ' s # 13 'SNEW:' SNEW, MTINFORMATION, [Mbok], 0); strdispose (snew); end; ## strnew, strdispose example ------------------------------------------------------------------------------------------------------------------ -------------------------------------------------- ------ StrPas converts the null-terminated string into a Pascal-Style string. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------ SYSUTILS function prototype Function StrPas (str: Pchar): String; paragrace Uses sysutils; const A: pchar = 'i love the smell of object pascal in the morning.'; Var s: string [79]; begin s: = StrPas A); canvas.textout (10, 10, s); {Note That The Following Also Works} Canvas.TextOut (10, 10, a); end; ------------------------------------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Terminated string. ---------------------------------------------- ----------------------------- Unit sysutils function prototype Function Strpcopy (DEST: PCHAR; Source: string): pchar; example Uses sysutils; var A: array [0..79] of char; s: string; begin s: = 'Honk if you know blaise.'; strpcopy (a, s); Canvas.Textout (10, 10, STRPAS) A)); Var Source: string; dest: array [0..20] of char; begin Source: = '???????? ??????'; StrPCopy (DEST, SOURCE); Messagedlg (DEST, MTINFORMATION , [Mbok], 0); End; -------------------------------------------------------------------------------------------------------------------------------- ------------------------------------- Strplcopy Copy Pascal-Style string to null-terminated strings (Designation length) ------------------------------------------- ------------------------------- Unit sysutils function prototype Function strplcopy (dest: pchar; const source: String; Maxlen: Cardinal: pchar; --------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------- -------------------------- Unit sysutils function prototype Function Strpos (str1, str2: pchar): PCHAR; Description Str1 master string str2 String EXAMPLE Uses sysutils; procedure TForm1.Button1Click (Sender TObject); var Location: PChar; begin if StrPos (PChar (Edit1.Text), PChar (Edit2.Text)) <> nil then ShowMessage ( 'Substring found') else ShowMessage ( 'Substring not found '); END; ------------------ Const Substr: PCHAR =' WWW '; var s, r: pchar; begin s: =' http: // www. Atrusk.ru/delphi/; r: = strpos (s, substr); if r <> nil damagedlg (r, mtinformation, [mbok], 0) Else Messagedlg ('?? ???????? ? ?????? url! ', MTerror, [Mbok], 0); end; ---------------------------------------------------------------------------------------------------------- ------------------------------------------------- STRSCAN The next address of the position of the child character in the mother character string. ------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------ Unit sysutils function prototype Function Str SCAN (Str: Pchar; CHR: Char): PCHAR; example {Return Pointer to Name Part of a full path name} Uses sysutils; function namepart (filename: pchar): Pchar; var p: pchar; begin p: = strrscan Filename, '/'); if p = nil dam p: = strrscan (filename, ':'); if p = nil the p: = filename; end; namepart: = p; end; var s: string; begin S: = STRPAS (NamePart ('c: /test.fil' )); Canvas.textout (10, 10, s); end; const s: pchar = 'myfile.zzz'; var r: pchar; begin r: = strrscan (s, '.'); {R: = ' .zzz '} messagedlg (r, mtinformation, [mbok], 0); END; ------------------------------- -------------------------------------------- STRSCAN Submail Location in the mother character. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------- Unit sysutils function prototype Function Strscan (Str: pchar; chr: char) : PChar; example uses SysUtils; function HasWildcards (FileName: PChar): Boolean; {Return true if file name has wildcards in it} begin HasWildcards: = (StrScan (FileName, '*') <> nil) or (StrScan (FileName , '?') <> nil); end; const p: pchar = 'c: /test.*'; Begin If Haswildcards (P) Then Can Canvas.TextOut (20, 20, 'THE STRING HAS WILDCARDS') Else Canvas.TextOut (20, 20, 'The String Doesn't Have Wildcards') End; Const S: Pchar =' http: //www.atrussk.ru '; var r: pchar; begin r: = strscan (s,' w '); {r: =' www.assk.ru '} messagedlg (r, mtinformation, [mbok], 0 END; -------------------------------------------------- -------------------------- Strupper will turn the string to uppercase letters. ------------- -------------------------------------------------- -------------- Unit sysutils function prototype Function Strupper (str: pchar): PCHAR; Sample Uses sysutils; const s: pchar = 'a funny string' begin canvas.textout (5, 10 StrPas (StrLower (s)) '' strpas (STRUPPER (S))); end; =========================== ============== Text-file routines text-file current =========================== ============== appended an archive for Append. -------------------------- -------------------------------------------------- - Unit System Function Prototype Procedure Append (var f: Text); Sample VAR F: TextFile; Begin If OpenDialog1.execute Then {BRING UPEN File Di Alog} begin assignfile (f, OpenDialog1.FileName); {Open file selected in dialog} append (f); {add more text ot} Writeln (f, 'appended text'); Closefile (f); {Close File, Save changes} End; End; Example Var f: textfile; begin if OpenDialog1.execute thr f {Open a text file} assignfile (f, openDialog1.filename); append (f); Writeln (f, 'i am appending some stuff to the end of the file.') ; {INSERT CODE Here That Would Require A Flush Closing The File} Flush (f); {ENSURES THAT THE TEXT WAS ACTUALLLY WRITTEN TO File} CloseFile (f); end; end; ## append, flush example ----- -------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------------------------ -------------------------------------------------- ----------- Unit System Function Prototype Function Eoln [(VAR f: Text)]: Boolean; Flush puts the data in buffer into disk. (For text file) Unit System function prototype Procedure Flush (var f: text); example var f: textfile; begin if OpenDialog1.execute1 begin {Open a text file} assignfile (f, openDialog1.FileName); append (f); Writeln (f, 'i am appending some stuffTo the end of the file. '); Flush (f); {ENSURES That Teth Was Actually Written to File} {INSERT CODE Here That Would Require A Flush Before Closing The File} CloseFile (f); End; End; Example Begin {tells program to wait for keyboard infut }writeln; end; --------------------------------- ---------------------------------------------- -------------------------------------------------- ------------------------- Unit System Function Prototype Procedure Read (f, V1 [, v2, ..., vn]); Procedure Read ([VAR F: Text;] V1 [, V2, ..., VN]); Example Uses Dialogs; Var F1, F2: TextFile; Ch: Char; Begin If OpenDialog1.execute The Begin AssignFile (F1, OpenDialog1 .FileName); Reset (f1); if Savedialog1.execute1 Begin AssignFile (F2, OpenDialog1.FileName); REWRITE (F2); While NOT EOF (f1) Do Begin Read (F1, CH); Write (F2, CH) ; End; Closefile (F2); end; closefile (f1); end; end. ---------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------ Readln read file. -------------------------------------------------- -------------------------- Unit system function Procedure readln ([var f: text;] v1 [, v2, ..., vn]); example var s: string; begin write ('Enter a line of text:); readln (s); WriteLn 'You type:', s); Writeln ('Hit I, J, Y: Inteder; Begin Assignfile (F, 'Test.txt'); ReWrite (f); {Create a file with 8 NumBers and some whitespace at the ends of the lines }writeln (f, '1 2 3 4 '); Writeln (f,' 5 6 7 8 '); reset (f); {read the number back. Seekeoln Returns True If there is no more numbers on the current line; seenkeof returns true if there is no more text (Other Than Whitespace) in the file.} Y: = 5; While Not Seekeof (f) Do Begin if Seekeoln (f) Then Readln; {Go To Next Line} Read (f, J); Canvas.TextOut (5, Y, INTTOSTR (J)); Y: = Y Canvas.TextHeight (INTTOSTR (J)) 5; end; end; --------------------- -------------------------------------------------- - ---- SEEKEOLN Test file is over. --------------------------------------- -------------------------------------- Unit system function prototype Function seekeoln [(VAR f: Text )]: Bolean; example var f: system.textfile; i, j, y: integer; begin assignfile (f, 'test.txt'); ReWrite (f); {create a file with 8 NumBers and some whitespace at the ends of the lines} Writeln F, '1 2 3 4'); Writeln (f, '5 6 7 8'); reset (f); {read the number on the current line; seekeof returns true; seekeof returns True; SeeKeof Returns True If there is no more text (other than whitespace) in the file.} Y: = 5; While Not Seekeof (f) Do Begin if Seekeoln (f) Then Readln; {Go To Next Line} Read (f, J); Canvas.Textout (5, Y, INTOSTR (J)); Y: Y: = Y Canvas.TextHeight (INTTOSTR (J)) 5; end; end; ## Seekeoln, seekeof example ------------------------- -------------------------------------------------- - setTextBUF Specifies I / O Buffer to Text File. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------- Unit System Function Prototype Procedure SetTextBuf (var f: Text VAR BUF [; SIZE: INTEGER]); paragrace Uses Dialogs; var f, ftwo: system.textfile; ch: char; buf: array [1..4095] of char; {4k buffer} begin if openDialog1.execute dam Begin AssignFile (f, paramstr (1)); {BIGGER BUFFER for Faster Reads} setTextBuf (F, BUF); Reset (f); {Dump text file {{dump text file inother file} assignfile (ftwo, 'woof.dog'); REWRITE (FTWO); while not Eof (f) DO Begin Read (f, ch); Write (ftwoch); end; system.closefile (f); system.closefile (ftwo); end; -------------------------------------------------- -------------------------- Write Write. ------------------ -------------------------------------------------- ------- Unit system function prototype Write (f, v1, ..., vn); Write ([var f: text;] P1 [, p2, ..., pn]); Procedure TFORM1 .Button3Click (Sender: TOBJECT); Var Stream: TBLOBSTREAM; S: String; Begin with Table1 Do Begin EDIT; Stream: = CreateBlobStream (FieldbyName ('Notes'), BmreadWrite; Try Stream.seek (0, 2); {Seek 0 Bytes from the stream's end point} s: = 'this Line will be added to the end.'; Stream.write (Pchar (s), Length (s)); Finally Stream.Free; End; Post; end; end; ---------------------- -------------------------------------------------- ----- Writeln Write into the file. -------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------- Unit system function prototype Procedure Writeln ([VAR f: text; ] P1 [, P2, ..., PN]); example var s: string; begin write; readln (s); writeln ('you type:', s); Writeln ('Hit {The letter 'A'} end; Example procedure TForm1.ComboBox1KeyPress (Sender: TObject; var Key: Char); var Found: boolean; i, SelSt: Integer; TmpStr: string; begin {first, process the keystroke to obtain the Current string} {this code requires all items in list to be uppercase} IF key in ['a' .. 'z'] THEN DEC (key, 32); {force Uppercase Only!} with (Sender As Tcombobox) Do Begin SELST: = SELSTART; IF (Key = chr (vk_back)) and (selLength <> 0) THENTMPSTR: = Copy (Text, 1, SELSTART) COPY (Text, Sellength SELSTART 1, 255) Else if key = chr (vk_back) THEN {SelLength = 0} Tmpstr: = Copy (Text, 1, SELSTART-1) COPY (Text, SELSTART 1, 255) Else {key in ['a'. 'Z', ETC]} Tmpstr: = Copy (Text, 1, SELSTART) Key Copy (Text, SelLength SELSTART 1, 255); if Tmpstr = 'Then EXIT; {Update selst to the current insertion point} IF (key = chr (vk_back)) and (selst> 0) THEN DEC (SELST) Else if Key <> chr (vk_back) THEN INC (SELST); key: = # 0; {inde selst = 0 dam; {Now TMPSTR IS The Currently Typed String, See IF We can Locate a match} Found: = false; for i: = 1 to items.count do if copy (items [i-1], 1, length (tmpstr)) = tmpstr the beginning: = items [i-1]; {UPDATE TO THE Match That Was Found} ItemIndex: = I-1; Found: = true; Break; End; if Found the String} Begin SELSTART: = SELST; SELLENGTH: = Length (Text) -Selst; End; end Else Beep; end; end; ## copy, chr, selstart, sellength example ------------------------------- -------------------------------------------- HIGH backfooted the biggest Value. ------------------------------------------------ ---------------------------- Unit System Function prototype Function High (x); example [Ordinal Type] Procedure TFORM1.BUTTON1CLICK (Sender : TOBJECT); Var low_s: string; high_s: string; s: string; begin high_s: = 'high =' INTOSTR (high (word)); low_s: = 'low =' INTOSTR (Low (Word)); s: = low_s High_s; label1.caption: = S; S: = Low = 0 high = 65535 [Array Type] Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); VAR P: Array [5..21] of double; low_s: string; high_s: string; s: string; begin high_s: = 'high =' INTOSTR ( High (p)); low_s: = 'Low =' INTTOSTR (Low (p)); s: = low_s high_s; label1.caption: = S; end; s: = low = 5 high = 21 [String Type] Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); VAR P: String [23]; low_s: string; high_s: string; s: string; begin high_s: = 'high =' INTOSTR (HIGH (P)) ; Low_s: = 'Low =' INTOSTR (Low (P)); s: = low_s high_s; label1.caption: = s; end; S: = LOW = 0 hight = 23 P: shortstring; s: = LOW = 0 hight = 255 P: String; long strings cannot be, there will be error signals. [Open array] function sum (var x: array of double): double; var i: word; s: double; begin s: = 0; {Note That Open array index range is always zero-based.} For i: = 0 TO HIGH (X) DO S: = S X [I]; SUM: = S; END; EXAMPLE FUNCTION SUM (VAR x: Array Of Double): Double; VAR i: Word; s: Real; begin s: = 0; {Note That Open Array Index Range is always zero-based.} for i: = 0 to high (x) do s: = s x [i]; Sum: = s; end; procedure tform1.button1click (sender: TOBJECT); Var list1: array [0..3] of double; list2: array [5..17] of double; x: Word; s, tempstr: string; begin for x: = low (list1) to high (list1) do List1 [x]: = x * 3.4; for x: = low (list2) to high (list2) do list2 [x]: = x * 0.0123; Str (SUM (List1): 4: 2, s); s: = 'Sum of list1: s # 13 # 10; s: = s ' sum of list2: '; Str (SUM (lis (list2): 4: 2, tempstr); S: = S Tempstr; Messagedlg (s, mtinformation, [mbok], 0); End; ## low, high example ---------------------- -------------------------------------------------- ----- Low passes the minimum of the foot. ------------------------------------- -------------------------------------- - Unit System Function Prototype Function Low (x); Description Ordinal type The lowest value in the range of the type Array type The lowest value within the range of the index type of the array String type Returns 0 Open array Returns 0 String parameter Returns 0 ----------- -------------------------------------------------- ----------------------------------------- -------------------------------------------------- - Unit system function prototype Function ORD (X): Longint; Example Procedure TFORM1.BUTTON1CLICK (Sen DER: TOBJECT); TYPE colors = (red, blue, green); var s: string; begin s: = 'blue Has An ORDINAL VALUE OFE' INTOSTR (ORD) # 13 # 10; s: = S 'THE ASCII Code for "C" IS' INTSTR (ORD ('c')) 'Decimal'; Messagedlg (S, Mtinformation, [Mbok], 0); -------------------------------------------------- --------------------------- Round converts the real numbers into integers. (Have four rounds) ------------ -------------------------------------------------- -------------- Unit system function prototype Function Round (x: extended): longint; example var s, t: string; begin STR (1.4: 2: 1, t); s : = T 'ROUNDS to' INTTOSTR (Round (1.4)) # 13 # 10; STR (1.5: 2: 1, t); s: = S T 'ROUNDS to' INTOSTR (Round (1.5 )) # 13 # 10; STR (-1.4: 2: 1, t); s: = S T 'ROUNDS to' INTOSTR (Round (-1.4)) # 13 # 10; STR (-1.5 : 2: 1, t); s: = S T 'ROUNDS to' INTOSTR (Round (-1.5)); MessageDlg (S, Mtinformation, [Mbok], 0); END; ------ -------------------------------------------------- -------------------- Trunc turns the real number into an integer. (Decimal directly abandoned) ---------- -------------------------------------------------- ---------------- Unit System Function prototype Function Trunc (x: Extended): longint; untyped file routines var s, t: string; begin STR (1.4: 2: 1, T); S: = T 'Truncs to' INTOSTR (Trunc (1.4)) # 13 # 10; STR (1.5: 2: 1, t); s: = S T 'Truncs to' INTOSTR (Trunc (1.5)) # 13 # 10; STR (-1.4: 2: 1, t); s: = S T 'Truncs to' INTOSTR (Trunc (-1.4)) # 13 # 10; STR (-1.5: 2: 1, t); s: = S T 'Truncs to' INTOSTR (Trunc (-1.5)); Messagedlg (S, Mtinformation, [MboK], 0); end; ----------------------- VARF: FILE OF INTEGER; I, J: INTEGER; Begin Assignfile (f, 'Test.int'); REWRITE (F ); For i: = 1 to 6 do Write (f, i); Writeln ('file before truncation:'); reset (f); While Not Eof (f) Do Begin Read (f, i); WriteLn (i ); End; reset (f); for i: = 1 to 3 do read (f, j); {read ahead 3 records} TRUNCATE (F); {cut file off heren} Writeln; 'file after truncation:'; reset (f); While Not Eof (f) DO Begin READ (F, I); Writeln (I); End; Closefile (f); ERASE (F); END; -------------------------------------------------- -------------------------- BLOCKREAD reads the file to the memory block. ------------- -------------------------------------------------- -------------- Procedure TFORM1.BUTTON1CLICK (Sender: Tobject); Var fromf, TOF: File; Numread, Numwritten: Integer; BUF: Array [1..2048] of char; if OpenDialog1.Execute then {open file dialog box} begin AssignFile (FromF, OpenDialog1.FileName); {} Reset (FromF, 1); {Record size = 1} if SaveDialog1.Execute then {Display Save dialog box} begin AssignFile ( TOF, Savedialog1.FileName); {Open Output file} Rewrite (TOF, 1); {record size = 1} canvas.textout (10, 10, 'Copying' INTOSTR (FileSize (fromf)) 'Bytes ...'); Repeat BlockRead (fromf, buf, sizeof BUF), Numread; Blockwrite (TOF, BUF, Numread, NumWritten); Until (NumRead = 0) or (NumWritten <> NumRead); Closefile (fromf); Closefile (TOF); end; end; end; ## blockread Blockwrite, Savedialog Example -------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------ BLOCKWRITE writes the memory block into the file. -------- -------------------------------------------------- ------------------- Unit System Function Prototype Procedure Blockread (var f: file; var buf; count: integer [; var result: integer); function prototype Procedure BlockWrite (var f: file; var buf; count: integer [; var result: INTE GER]); Example var FromF, ToF: file; NumRead, NumWritten: Integer; Buf: array [1..2048] of Char; begin if OpenDialog1.Execute then {Display Open dialog box} begin AssignFile (FromF, OpenDialog1.FileName ); Reset (FromF, 1); {Record size = 1} if SaveDialog1.Execute then {Display Save dialog box} begin AssignFile (ToF, SaveDialog1.FileName); {Open output file} Rewrite (ToF, 1); {Record Size = 1} Canvas.Textout (10, 10, ' Copying ' INTOSTR (FileSize (fromf)) ' Bytes ... '); Repeat Blockread (fromf, buf, sizeof (buf), numread; block, buf, numread, numwritten; until (NumRead = 0 ) or (NumWritten <> Numread; Closefile (fromf); Closefile (TOF); end; end; end; =========================== ============= Variant Support Routines ghost variable in the function ============================== ========= VararrayCreate creates a Variant Array. ---------------------------------- ----------------------------------------- Unit System Function Prototype Function Vararraycreate (Const Bounds: Array Of Integer; VARTYPE: INTEGER: VARIANT; Sample Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); VAR A: Variant; s: String; Begin A: = VARARAYCREATE ([0, 4], Varvariant); A [0]: = 1; A [1]: = 1234.5678; a [2]: = 'Hello World'; a [3]: = true; A [4]: = varRayof ([1, 10, 100, 10000]); s: = a [4] [2]; s: = a [2] ' S; label1.caption: = S; END; Description S: = a [4] [2]; Variant can be converted without functions. Can only be used alone, if it is incorrectly, s: = a [2] ' a [4] [2] ; VarType varEmpty $ 0000 The variant is Unassigned varNull $ 0001 The variant is Null varSmallint $ 0002 16-bit signed integer (type Smallint) varInteger $ 0003 32-bit signed integer (type Integer) varSingle $ 0004 Single-precision floating-point value (.... type Single). varDouble $ 0005 Double-precision floating-point value (type Double). varCurrency $ 0006 Currency floating-point value (type Currency). VarDate $ 0007 Date and time value (type TDateTime). VarOleStr $ 0008 Reference to a dynamically allocated UNICODE string Vardispatch $ 0009 Reference to An Ole Automation Object (An IDispatch Interface Pointer). Varrror $ 000A Operating System Error Code. Varboolean $ 000B 16-bit Boolean (T ype WordBool). varVariant $ 000C Variant (used only with variant arrays). varUnknown $ 000D Reference to an unknown OLE object (an IUnknown interface pointer). varByte $ 0011 8-bit unsigned integer (type Byte). VarString $ 0100 Reference to a dynamically -allocated long string (type AnsiString). varTypeMask $ 0FFF bit mask for extracting type code. This constant is a mask that can be combined with the VType field using a bit-wise AND .. varArray $ 2000 bit indicating variant array. This constant is a mask that can be combined with the VType field using a bit-wise AND to determine if the variant contains a single value or an array of values. VarByRef $ 4000 This constant can be AND'd with Variant.VType to determine if The Variant Contains a Pointer to The Compicated Data ITSelf. Example VAR V1, V2, V3, V4, V5: Variant; I: Integer; D: Double; S: String; Begin V1: = 1; {Integer Value} V2: = 1234.5678; {real value} v3: = 'Hello World '; {string value} v4: =' 1000 '; {string value} V5: = V1 V2 V4; {real value 2235.5678} i: = v1; {i = 1} D: = V2; {d = 1234.5678} S: = v3; {s = 'hello world'} i: = v4; {i = 1000} s: = v5; {s = '2235.5678'} end; ----------- -------------------------------------------------- ----------------- Vararrayof builds a simple one-dimensional Variant Array ----------------------- -------------------------------------------------- - Unit System Function Prototype Function Vararrayof (Const Values: array of variant): variant; sample var A: Variant; Begin A: = Vararrayof ([1, 10, 'Hello, 10000]); s: = a [1] ' ' INTOSTR (a [2]); label1.caption: = S; end; -------------------------------------------------- ---------------------------------------------------- -------------------------------------------------- --------------- Unit system --------------------------------- -------------------------------------------- Function Prototype Procedure Vararrayredim (VAR A: VARIANT; HIGHBOUND: Integer; -------------------------------------------------- ------------------------------------------------------------------------------------------------------------ -------------------------------------------------- ------------ Unit System Function Prototype Function Vararraydimcount (Const A: Variant): Integer; ---------------------- -------------------------------------------------- ----- VararrayHighbound passed back to a Variant array of high note. --------------------------------- ------------------------------------------ Unit System Function Prototype Function VararrayHighBound (Const A: Variant; DIM: Integer): Integer; ---------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------- Failed. ------------------------------------------------ ----------------------------- Unit System Function prototype Function VaRraylowBound (const A: variant; dim: integer): Integer Example procedure tform1.button1click (sender: Tobject); var A: variant; count: integer; highbound: integer; lowbound: integer; i: integer; s: string; begin a: = varingcreate ([0, 5, 1, 3], Varvariant; count: = varRaydimcount (a); s: = # 13 'dimension:' INTOSTR (count) # 13; for i: = 1 to count do beg highbound: = varrrrayhighbound (A, i); lowbound: = varagelowbound (a, i); s: = s 'highbound:' intent (highbound) # 13; S: = S 'Lowbound:' INTOSTR (Lowbound) # 13; End; ShowMessage (s); end; ------------------------ -------------------------------------------------- --- VararrayLock Specifies the Variant Array ==> to an array variable. -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------- Vararrayunlock releases the above designation. -------------------------------------------------- -------------------------- Unit System Function prototype Function Vararraylock (var A: Variant): Pointer; Function Prototype Procedure Vararrayunlock (var A: Variant ); Example procedure tform1.button1click (sender: Tobject); const highval = 12; type tdata = array [0..highval, 0..highval] of integer; var A: Variant; i, j: integer; data: ^ TDATA; Begin A: = VararrayCreate ([0, HIGHVAL, 0, HIGHVAL], VARINTEGER); For i: = 0 to highval do for j: = 0 to highval do a [i, j]: = i * j; data: = varagelock (a); for i: = 0 to highval do for j: = 0 To Highval do grid1.cells [i 1, j 1]: = INTOSTR (data ^ [i, j]); varArRayunlock (a); end; ---------------- -------------------------------------------------- ----------- VarisArray Pass whether it is an array. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- Unit system function Prototype Function VarisArray (Const v: Variant): Boolean; VariTyMpty is not registered. (Empty) Unit system function prototype Function VariSempty (const v: variant): boolean; example procedure tform1.button1click (sender: TOBJECT); var A: s: string; begin A: = VararrayCreate ([0, 5, 0, 7], Varvariant); if varisempty (a) THEN S: = 'true' else s: = 'false'; label1.caption: = s; end; ----- -------------------------------------------------- ---------------------- ** s: = false, A is created. --------------- -------------------------------------------------- ------------ Varisnull is returned to whether Variant is NULL. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------- Unit system function Prototype Function Varisnull (Const V: Variant): Boolean; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------- ------------- VaraStype turns Variant to another type of Variant. ------------------------- -------------------------------------------------- - VARCAST ----------------------------------------------- ----------------------------- Unit System Function Prototype Function VaraSType (const v: variant; variant; functions Prototype Procedure Varcast (var at: variant; variant; variant; VARTYPE: Integer); Note Vartype cannot be VARARRAY or Varbyref. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------- Vartype returns to Variant's style. ------- -------------------------------------------------- ------------------- Unit system function prototype Function VARTYPE (Const v: Variant): Integer; --------------- -------------------------------------------------- ------------ VARCLEAR Clear Variant and became a unassigned state. ----------------------------- ---------------------------------------------- Unit System Function prototype procedure varclear (var variant); --------------------------------------- -------------------------------------- VARCOPY copys a variant. ------- -------------------------------------------------- ------------------- Unit System Function prototype Procedure Varopy (var at: variant; const source: variant); Description and Dest: = Source; effect is the same. - -------------------------------------------------- ----------------------- VarfromDatetime turned DateTime to Variant. -------------------- -------------------------------------------------- ------- VartodateTime converts Variant to Datetime. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ---------------------------------------- Unit system function prototype Function VarfromDatetime (DateTime: TDATETIME): Variant; Function prototype Function VartodateTime (const v: variant): tdatetime; ============================= function ============================================================================================================================================================================= ========== Procedure TFORM1.BUTTON2CLICK (Sender: Tobject); var Bitmap: Tbitmap; Begin Bitmap: = tbitmap.create; try bitmap.LoadFromFile ('g: /33.bmp'); Form1. Canvas.brush.bitmap: = Bitmap; Form1.canvas.FillRect (RECT (0, 0, 18, 15)); Finally Form1.canvas.brush.bitmap: = nil; Bitmap.Free; end; end; ## canvas , Brush, bitmap, fillRect example ============================================================================================================================================================================================================ =========================================================================================================================================00 var HeaderSection: THeaderSection; I: Integer; begin for I: = 0 to 4 do begin HeaderSection: = HeaderControl1.Sections.Add; HeaderSection.Text: = 'Text Section' IntToStr (I); HeaderSection.MinWidth: = length ( HeadersECTION.Text) * font.size; // Owner Draw Every HEADERSECTION.STYLE: = HSOWNERDRAW ELSE HeadersECTION.Style: = HSTEXT; END; procedure TForm1.HeaderControl1DrawSection (HeaderControl: THeaderControl; Section: THeaderSection; const Rect: TRect; Pressed: Boolean); begin with HeaderControl.Canvas do begin // highlight pressed sections if Pressed then Font.Color: = clRed else Font.Color: = CLBLUE; TextOut (Rect.Top Font.Size, Rect.top 2, 'Owner Drawn Text'); End; End; ## HeadersECTION, ONDRAWSECTION, Sections, Canvas, TextOut Example --------- ------------------------------------ Trunc Example ------------------------------------- ---------- Procedure TFORM1.BUTTON1CLICK (Sender: Tobject); Var S, T: String; Begin Str (1.4: 2: 1, t); s: = T 'Truncs to' INTOSTR (Trunc (1.4)) # 13 # 10; STR (1.5: 2: 1, t); s: = S T 'Truncs to' INTOSTR (Trunc (1.5)) # 13 # 10; STR (-1.4: 2: 1, T); s: = S T 'Truncs to' INTOSTR (Trunc (-1.4)) # 13 # 10; STR (-1.5: 2: 1, T); S: = S T 'Truncs to' INTOSTR Trunc (-1.5)); Messagedlg (S, Mtinformation, [Mbok], 0); Not classified ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- SYSUTILS TYPE TSYSCHARSET = set of CHAR VAR S, R: STRING; Begin S: = '123456_123456_123456'; R: = WrapText (s, # 13 # 10, ['1', '4'], 4); Messagedlg (r, mtinformation, [mbok] , 0); end; ========================================== widechartostrvar (Source: PWIDECHAR; VAR DEST: STRING); ------------------------- System ---------------- ======= ================== widechartostring (Source: pwidechar): String; ----------------------- - SYSTEM ============================= widecharlentostrvar (Source: pWideCha); ---); ----- ------------------------- system ======================== ====== widecharlentostring (Source: pWideCha): String ----------------------- system ======== ==================== AnsicompareFileName (const S1, s2: string): integer; sysutils ================= ================== rsiextractquotedstr (var s: pchar; quote: char): string; s2:/?? . ???????????????.56/ '; s2: = ANSIEXTRACTQUOTEDSTR (S1,' / '); // s2: =' ??. ????????? ? 'Messagedlg (S2, Mtinformation, [Mbok], 0); End; --------------------------------- ------------------------- AnsilastChar (Const S : pchar; sysutils ---------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------- AnsilowerCaseFileName (const S: string): string; sysutils --------------------------------------- ------------------- ANSIPOS (Const Substr, S: String): Integer sysutils var substr, s: string; i: integer; begin s: = '??? ????? ?????? '; substr: =' ??? '; i: = ANSIPOS (Substr, S); // i: = 3 ... End; ------- -------------------------------------------------- - ANSIQUOTEDSTR (const s: string; quote; s: = '1997-1998 ??.'; S: = ANSIQUOTEDSTR (S: =); // s: = '-1997--1998 ?? .-' Messagedlg (s, mtinformation, [mbok], 0); End; -------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------- ANSISAMESTR (Const S1, S2: String): Boolean; sysutils --- -------------------------------------------------- ----- ANSISAMETEXT (Const S1, S2: String): Boolean; Sysutils ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------- ANSISTRCOMP (S1, S2: PCHAR): Integer sysutils --------------------------------------- ------------------- Ansistricomp (S1, S2: PCHAR): Integer; sysutils ------------------- --------------------------------------- ANSISTRLASTCHAR (P: PCHAR): Pchar; Sysutils -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------ AnsistrolComp (S1, S2: PCHAR; MAXLEN: Cardinal): Integer; SYSUTILS VAR P1, P2: PCHAR; LEN: Integer; Begin P1: = '??????????????? ????????????????????????? ????????. '; P2: =' ?????? ?????????? ???????? ?? ??????! '; Len: = length (p1) -1; if Ansistrlicomp (P1, P2, LEN) = 0 Then Messagedlg (p1 # 13 p2 # 13 "?????? ???????? ?????? ' INTOSTOSTR (LEN) "?????????, ?????, mtinformation, [mbok], 0); end; -------------------------------------------------- ------ Ansistrlicomp (S1, S2: PCHAR; MAXLEN: Cardinal): Integer; SYSUTILS VAR P1, P2: PCHAR; LEN: Inteder; Begin Len: = 7; P1: = '?????? 1'; P2: = '?????? 2'; if Ansistrlicomp (P1, P2 , LEN) = 0 Then Messagedlg (p1 # 13 p2 # 13 '??????? ??????????????' INTOSTR (LEN) '??? ?????, ????? ', mtinformation, [mbok], 0); end; ------------------------------------------------------------------------------------------------------------------------------------------------------------------ -------------------------------- ANSISTRLOWER (S1, S2: PCHAR): PCHAR; SYSUTILS ------ -------------------------------------------------- - Ansistrpos (S, Substr: Pchar): Pchar Sysutils Var S1, S2: PCHAR; Begin S1: = '????? ???? -? ????? ????!'; S2: = Ansistrpos (S1, '?????'); // s2: = '????? ????!' Messagedlg (S2, Mtinformation, [Mbok], 0); End; ------ -------------------------------------------------- - ANSISTRRSCAN (S: Pchar; Chr: Char): PCHAR; SYSUTILS VAR P1, P2: PCHAR; Begin P1: = 'C: / Windows / Temp'; P2: = ANSISTRSCAN (P1, '/'); {P2 : = '/ TEMP'} Messagedlg (P2, Mtinformation, [Mbok], 0); End; -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Begin P1: = 'http://www.atrussk.ru/delphi'; p2: = ANSISTRSCAN (P1, '/'); {P2: = '//www.atrussk.ru/delphi'} Messagedlg (P2, Mtinformation, [Mbok], 0); End; ----------------------- ---------------------------------- Ansistrupper (s: pchar): Pcharsysutils ------- -------------------------------------------------- - ANSIUPPERCASEFILENAME (Const S: String): String; SYSUTILS ------------------------------------- --------- Bytetocharindex (Const S: String; Index: Integer): Integer; SYSUTILS ------------------------------------- --------- bytetocharlen (const s: string; maxlen: integer): integer; sysutils ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------- ByType (Const S: String; Index: Integer): TMBCSBYTYPE; SYSUTILS MBSINGLEBYTE - MBLEADBYTE - MBTRAILBYTE - -------------------------------------------------------------------------------------------------------------------------------------------------- --------------- Chartobyteindex (Const S: String; Index: Integer): Integer; SYSUTILS ------------------------------------- --------- Chartobytelen (Const S: String; Maxlen: Integer): Integer; SYSUTILS ------------------------------------- --------- CHR (x: byte): char; SYSUTILS Messagedlg ('ASCII - ????? 77 ???????????????????? CHR (77), Mtinformation, [Mbok], 0); --- -------------------------------------------------- ----- FormatmaskText (Const Editmask: String; Const Value: String): String; Mask ----------------------------------------------------------------------------------------------------------- --------- GetformatSettings; SySUTILS -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------- Isdelimiter (Const Delimiters, S: String; Index: Integer): Boolean; Sysutils var s: string; begin s: = '???????, ?????? ??????????!; If isdelimiter ('!, - ', s, 8) THEN Messagedlg ('???????!', Mtwarning, [mbok], 0) else messagedlg ('??????????!', Mtwarning, [mbok], 0); End; ---------------------------------------------------------------- ---------- IsPathDelimiter (const s: string; index: integer): boolean; sysutils if ispathdelimiter (s, length (s)) THEN S: = Copy (S, 1, Length (s) -1); -------------------------------- -------------------------- LastDelimiter (Const Delimiters, S: String): Integer; sysutils var i: integer; begin i: = lastdelimiter '!;., -', '???????, ??????, ??????????'); // i: = 16 end; ----- -------------------------------------------------- --- Linestart (Buffer, BUFPOS: PCHAR): Pchar Classes - ---------------------------------- ---------------------- Quotedstr (const s: string): string; sysutils ----------------- ----------------------------------------- SETLENGTH (VAR S; Length: Integer) ; System ---------------------------------------------------------------------------------------------------------- ------------ SetString (var s: string; buffer: pchar; length: integer); System ------------------------------------- --------- Str (x [: width [: decimals]; var s); system var String; i: real; Begin I: = -52.123456789; STR (i: 6: 2, s); {s: = '-52.12'} Messagedlg (s, mtinformation, [mbok], 0); end; --------- ------------------------------------------------- Strbufsize (S: pchar): cardinal; sysutils ----------------------------------------- ----------------- Strbytetype (s: pchar; index: cardinal): TMBCSBYTYPE; SYSUTILS -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------- StringOfchar (ch: char; count: integer): String; System s: = StringOfchar ('.', 3); // s: = '...' --------------------------- ------------------------------ StringReplace (Const S, Oldsubstr, NewsUbstr: String; Flags: TreplaceFlags): String; sysutils TYPE TREPLACEFLAGS = Set of (RFREPLACEALL, RFIGNORECASE); Var s: string; flags: TreplaceFlags; begin flags: = [RFREPLACEALL, RFIGNORECASE]; s: = '???? - ????? ?????'; s: = StringReplace (s, '?? ',' ?? ', flags; // s: =' ???? - ????? ????? '} messagedlg (s, mtinformation, [mbok], 0); end; -------------------------------------------------- -------- StringTowideChar (Const Source: String; DEST: PWIDECHAR; DESTSIZE: INTEGER): PWIDECHAR System ------------------------------------- --------- UniqueString (var s: string); System ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ---------------------------- ============================== message ========================================================================================================================================================================= =========== ------------------------------------- ------------------------ SHOWMESSAGE ------------------------ --------------------------------------- Procedure TFORM1.BUTTON1CLICK (Sender: Tobject); VAR buffer: array [0..255] of char; FileToFind: string; begin GetWindowsDirectory (buffer, SizeOf (buffer)); FileToFind: = FileSearch (Edit1.Text, GetCurrentDir ';' buffer); if FileToFind = 'then ShowMessage ('couldn't Find'. ') Else ShowMessage (' Found ' FileTOfind '); End; ## filesearch, showMessage Example ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------- Findcomponent Example (1) Type Logpal = Record LPAL: TLOGPALETTE; DUMMY: Array [0..255] of tPaletteEntry; procedure TForm1.SaveAsBmpClick (Sender: TObject); var Source: TComponent; SysPal: LogPal; tempCanvas: TCanvas; sourceRect, destRect: TRect; image2save: TImage; notUsed: HWND; begin Source: = FindComponent (Edit1.Text); if ( NOT SOURCE IS TCONTROL) OR ((NOT Source Is Twincontrol) and (Source As Tcontrol) .parent = nil)) Thenbegin Beep; ShowMessage (Edit1.Text 'Is Not a Valid Control.'); END; tempCanvas: = TCanvas.Create; try with Source as TControl do tempCanvas.Handle: = GetDeviceContext (notUsed); image2save: = TImage.create (self); try with image2save do begin Height: = (Source as TControl) .Height; Width : = (Source as tcontrol) .width; DestRect: = Rect (0, 0, width, height); if Source is TwinControl Then sourceRect: = destRect; else sourceRect: = (Source as TControl) .BoundsRect; Canvas.CopyRect (destRect, tempCanvas, sourceRect); SysPal.lPal.palVersion: = $ 300; SysPal.lPal.palNumEntries: = 256; GetSystemPaletteEntries (tempCanvas. Handle, 0,256, syspal.lpal.palpalent; picture.bitmap.palette: = createpaalette (syspal.lpal); end; if Savedialog1.execute1 Image2Save.Picture.Savetofile (Savedialog1.FileName); Finally Image2Save.Free; end; fin or tempcanvas.free; end; end; example (2) Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); Var i: integer; const nameprefix = 'myEdit'; Begin for i: = 1 to 20 do begin tedit.create (self) .Name: = NamePrefix INTOSTR (i); with TEDIT (Findcomponent (NamePrefix INTSTR (i) )))); top: = i * 20; parent: = self; end; end; end; ======================= =================================================================, Sender: Tobject; A: = VararrayCreate ([0, 4], Varvariant); A [0]: = 1; A [1]: = 1234.5678; a [2]: = 'Hello World'; a [3]: = true; A [4]: = VararrayOf ([1, 10, 100, 1000]); edit1.text: = (a [2]); {Hello World} Edit2.text: = (a [4] [2]); { 100} end; procedure TFORM1.BUTTON2CLICK (Sender: TOBJECT); var s: string; begin s: = 'honest abe lincoln'; delete (s, 8, 4); canvas.textout (10, 130, s); {'honest lincoln'} END; Procedure TForm1.Button3Click (Sender: Tobject); var s: string; begin s: = 'Abcdef'; s: = COPY (S, 2, 3); edit1.text: = s; {'bcd'} end; procedure TFORM1.BUTTON4CLICK (Sender: TOBJECT); var s: string; begin s: = concat ('abc', 'DEF'); edit1.text: = s; {'abcde'} end; Procedure TForm1.Button5Click (Sender: Tobject); var s: string; begin s: = 'honest lincoln'; insert ('Abe', s, 8); edit1.text: = s; {'honest Abe lincoln'} end ; Procedure TForm1.Button6Click (Sender: TOBJECT); var s: string; begin s: = 'THE Black knight'; canvas.textout (10, 130, 'string length =' INTOSTR (Length (s))); {String Length = 16} Edit1.Text: = S; {THE Black Knight} END; Procedure TForm1.Button7Click (Sender: Tobject); var s: string; begin s: = '123.5'; {Convert Spaces to Zeroes} While Pos ('', s)> 0 do s [POS ('', s)] : = '0'; edit1.text: = s; {000123.5} end; ================================ ==============================================Mathematics function (Arithmetic Routines) Unit: system ================================================ ====================================================================00 = Function ABS (X); Arctan is transmitted back to the reverse function value of the normal cut function. Function Arctan (x: Real): Real; CoS Biography Function Function COS (X: REAL): REAL; (x in an arc). EXP is sent back to the natural index value. Function COS (X: REAL): REAL; FRAC is transmitted back to the decimal part of the number. Integer Site of the INT Reed. Function INT (X: REAL): REAL; LN Removes Natural Alignment. Function LN (X: REAL): REAL; PI Removes the value of the circular rate π. Function PI: REAL; SIN is transmitted back the string function value. Function SIN (X: REAL): REAL; SQR is sent back to the number of. Function SQR (X: REAL): (REAL); SQRT back the square root of the number. Function SQRT (X: REAL): REAL; ======================================== =================================== console routines ======== ============================================================================================================================================================================================================= ================= Unit: WinCRT function name function description function syntax ========================= ============================================================================================================================================================================================================= = AssignCRT links the text file to a console window. Procedure AssignCRT (var f: text); Clreol Cleout Cursor position to all the characters of the line. PROCEDURE CLREOL; CLRSCR Clean the screen and reset the cursor to the upper left corner. Procedure CLRSCR; CURSORTO mobile cursor to a given seat. Procedure CursorTo (X, Y: Integer); DonewinCRT ends the console window. Procedure donewincrt; gotoxy mobile cursor to a given seat. Procedure gotoxy (x, y: byte); INITWINCRT establishes a console window. Procedure initwincrt; keypressed determines if there is a button. Function Keypressed: Boolean; Readbuf is read from the console site. Function Readbuf (Buffer: Pchar; Count: Word): ReadKey Reads button. Function Readkey: Char; Scrollto Rolling Control Table and Windows to Display Location. Procedure ScrollTo (X, Y: Integer); TrackCursor rolling control desktop window is visible to the cursor. Procedure TrackCursor; Wherex Retrieves the X coordinate of the target. Function wherex: Byte; Wherey passed back the y mark of the target. Function where: Byte; WriteBuf is written to a block of blocks to the console window. Procedure WriteBuf WriteChar writes a character to the console window. Procedure writechar (ch: char); ============================================= ======= Date and time function (Date and time routines) unit: systemils ============================== ========== Date Remove today. Function date: TDATETIME; DateTimetostr Transfers the time format into a string. Function dateTimetostr (datetime: tdatetime): String; DateTimetostring converts the time format into a string. Procedure DateTimetostring (Var Result: string; "DateTime: tdatetime); DateTostr transfers the date format into a string. Function datetostr (date: tdatetime): String; dayofweek is coming back today. Function Dayofweek (date: tdatetime): Integer; Decode Decomposition The date specified by the year, month, day. Procedure decodedate (Date: Tdatetime; var Year, Month, day: word); DecodeTime Decomposition The date specified is time, minute, second. Procedure Decodetime (Time: Tdatetime; Var Hour, min, sec, msec: word); Encodedate is transmitted back to the date format combined with the year, month, and Japan. Function EncodeDate (Year, Month, Day: Word): TDATETIME; ENCODetime is sent back to time, divided, minute, secondary time format. Function EncoDetime (Hour, min, sec, msec: word): tdatetime; formatDatetime backs the dateTree in the specified format. Function formatdatetime (const format: string; datetime: tdatetime): String; Now Retrieves the current date time. Function now: TDATETIME; Strtodate converts the strings into a date format. Function start: tdatetime; StrtodateTime converts strings to date time format Function StrtodateTime (const String): TDATTIME; Strtotime converts strings to time format. Function Strtotime (const s: string): tdatetime; Time is backup current time. Function Time: TDATETIME; Timetostr will turn the time to string. Function Timetostr (Time: tdatetime): String; ========================================= Dynamic Allocation Routines Unit: System ======================================== = Dispose releases back a dynamic variable. Procedure Dispose (VAR P: POINTER); Free releases an object copy. Procedure Free; FreeMem Releases a dynamic variable of a given size. Procedure FreeMem (size: word); getMem creates a dynamic variable specified by a specified size and is transmitted by the Pointer. Procedure getmem (var P: Pointer; SIZE: WORD); New builds a new dynamic variable and pointing the Pointer parameter to it. Procedure New (VAR P: POINTER); Function New ( Function ExtractFilePath (const filename: string): String; Fileage Replies the files of the file FUNCTION Fileage (const filename: String): longint; filecreate establishes a file with the specified file name. Function FileCreate (const filename: string): Integer; FileClose Close the specified file. ProcedureFileClose (Handle: Integer); FileDateTodateTime converts DOS's date format to Delphi's date format. Function FileDateTodateTime (FileDate: longint): tdatetime; FileExists discriminates if the file exists. Function FileExists (const filename: string): boolean; FileGetAtTR Remove file properties. Function Filegetttr (const filename: string): Integer; FilegetDate Retrieves the date and time of the file. Function Filegetdate (Handle: Integer): longInt; FileRead reads information from the specified file. Function FileRead (Handle: Integer; Count: longint): longint; filesearch searches for specified files in the directory column. Function FileSearch (constname, dirlist: string): String; Fileseek changes the location of the archive cursor. Function Fileseek (Handle: Integer; ORIGIN: Integer: longint; filesetattr Sets the 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 enables the file. Function Fileopen (const filename: string; mode: word): Integer; FileWrite write information to the file. Function FileWrite (Handle: Integer; Count: longint): longint; FindClose terminates the first / next action. Procedure FindClose (VAR Searchrec: Tsearch "; Findfirst Looking for the first fitted file and set its properties. Function Findfirst (const path: string; attr: word; var f: tsearchrec): integer; FindNext Removes the next compliant file. Function FindNext (VAR F: TSEARCHREC): Integer; renamefile change the file name. Function renamefile (const6ame: String): boolean; ==================================== === floating-point conversion function (floating-point conversion routines) Unit: systemils ================================== ======= Floattodecimal divides the floating point numerical (digital transmission of the decimal and integer part. Procedure floattodecimal (Value: Extended; Precision, DeciMals: Integer); floattostrf converts floating point numbers into a string description in accordance with the specified format. Function floattostrf (value: tfloatformat; precision, digits: integer): String; floattostr Transfers floating point number into a string description. Function floattostr (value: extended): string; floattotext will pass the floating point value, divided into decimal and integer partial part in accordance with the format. Function floattotext (buffer: pchar; value: extended; format: tfloatformat; precision, digits: integer: integer; floattotextFMT Transfer floating point number into a string back in accordance with the format. Function floattotextfmt (buffer: pchar; value: integer; formatfloat) Refers to the Format format in accordance with the format format. Function formatfloat (constformat: string; value: extended): String; StrtOFLOAT converts the string to a floating point value. Function StrtOFLOAT (const S: String): EXTENDED; TextTOFLOAT converts a NULL end string into floating point numerical Function TEXTTTOFLOAT (BUFFER: PCHAR; VAR value: Extended): boolean; ============ ============================ Flow-control routines unit: system =========== ===================================== Break terminates the ring. Returning in For, While and Repeat. Procedure Break; Continue continues to return the ring. Returning in For, While and Repeat. Procedure Continue; EXIT leaves the current block. Procedure exit; Halt stop program execution and return to the job system. Procedure Halt [(EXITCODE: WORD)]; RUNERROR stop program execution. Procedure RuNerror [(ErrorCode: Byte)]; ======================================== Output function (I / O Routines) unit: system ======================================= == AssignFile Specifies a file to file variable. Procedure assignfile (var f, string); Closefile Close the file. Procedure Closefile (var f); EOF determines if it has arrived at the end of the file. TYPED or UNYPED Files: FunctionEOF (VAR f): Booleantext Files: Function EOF [(VAR f: text)]: boolean; ERASE clears file content. Procedure Erase (VAR F); FilePOS is passed back to the current file cursor position. Function FilePos (VAR f): longint; FileSize Replies Size Function FileSize (var f): longint; getDir passed back to the working directory of the specified disk. Procedure getDir (d: byte; var s: string); iResult is transmitted back to the status of the last I / O execution. Function iiResult: integer; MKDIR creates a subdirectory. Procedure mkdir (s: string); rename Changes the file name of the external archive. Procedure rename (var f; newname); RESET turns on an existing file. Procedure Reset (VAR F [: File; RecSize: Word]); REWRITE is established and turned on. Procedure Rewrite (var f: file [; recsize: word]); RMDIR deletes an empty directory. Procedure RMDir (S: String); SEEK mobile archive cursor. Procedure Seek (VAR F; N: longint); Truncate deletes file content after the current location. Procedure truncate (var f); ========================================= Memory management Function Memory-Management Routines) Unit: systemils ================================================ Allocmem Configure a memory block to accumulate HEAP. Function Allocmem (Size: cardinal): Pointer; ReallocMem Removes a block from the accumulation. Function Reallocmem (p: Pointer; CURSIZE, NEWSIZE: cardinal): Pointer; ==================================== ====== Miscellaneous Routines Unit: system, sysutils ================================= ======= AddExitProc Add a program to the executive period library. Procedure addExitProc (Proc: tprocedure); Exclude removes an element from a collection. Procedure Exclude (Var S: set of t; i: t); FillCha fills in a variable number to a variable in one by a character. Procedure Fillchar (VAR X; Count: Word; Value); HI's high tuple of the number of. Function Hi (x): byte; include the element into the collection. Procedure Include (Var S: set of t; i: t); LO transmission back to the low talent group. Function lo (x): byte; Move Copy the number of points in the count of counts from the Source to DEST. Procedure Move (Varsource, Dest; Count: Word); paramcount passed the number of commands. Function paramcount: Word; Paramstr is sent back to a specified command column number. Function paramstr (index): string; Random is returned to a random mess. Function Random [(RANGE: WORD)]; Randomize initialized chaos generator. Procedure randomize; SIZEOF is transmitted back to the number of components of the number. Function SizeOf (X): Word; SWAP exchanges the high tuning and low tuning of the number. Function swap (x); TypeOf autism comes back to the indicator of the virtual method table of the object type. Function TypeOf (X): Pointer Upcase converts the character to uppercase. Function Upcase (CH: Char): char; ========================================= Ordinal routines unit: system ======================================== DEC Decrease a variable. Procedure dec (VAR x [; N: longint]); incaps a variable procedure inchaptive; VAR X [N: longint]); ODD discrimination is odd. Function ODD (x: longint): Boolean; PRED pass back the predecessor of the number. Function PRED (X); SUCC's successor. Function succ (x); ========================================= Indicator and address Pointer and address routines unit: system ========================================== Addr is transmitted back to the address of the specified object. Function addr (x): Pointer; Assigned determines whether a function or program is NIL Function Assigned (VAR P): Boolean; CSEG is transmitted back to the CS segment segment specification. Function CSEG: Word; DSEG Removes the content of the DS data segment specification. Function DSEGT: Word; OFS Transmission back the offset site. Function OFS (X): Word; PTR combines the specified segment and offset bit to an indicator. Function PTR (SEG, OFS: WORD): Pointer; SEG is sent back to the segment address of the number. Function seg (x): Word; SPTR is transmitted back to the SP stacker. Function SPTR: Word; SSEG Removes the contents of the SS stack segment scaler. Function SSEG: WORD; ==========================================================================★ String-formatting routines) Unit: sysutils ================================================== The numbers listed in accordance with the format of Format to the Result string back. Procedure FMTSTR (var resut: string; const args: array of const); Format combines the column number in accordance with Format's format to the Pascal format string back. FONCTION FORMAT (const format: string; const args: array: const): string; formatbuf formatted the number of queues listed. FormatBuf (var Buffer; BufLen: Cardinal; const Format; FmtLen: Cardinal; const Args: array of string): Cardinal; function FormatBuf (var Buffer; BufLen: Word; const Format; FmtLen: Word; Const Args: array of const) : Word; Strfmt formats the number of 叁 listed. Function strfmt (buffer, format: pchar; const args: array of const): PCHAR; SYSUTILS STRLFMT Format the number of 叁, pointing the result to the buffer metrics. Function strlfmt (buffer: pchar; mxlen: Word; Format: pchar; const args: array of const): pchar; sysutils ================================= ================ String-handling routines: pascal-style) unit: systutils ================= ======================================= Ansicomparestr compares two strings. Function AnsiCompareStr (consT S1, S2: String): Integer; sysutils var s: string; mas: array [0..99] of string; i, j: integer; begin ... for i: = 1 to 98 do for J: = i 1 to 99 DO if AnsicompareStr (mas [i], mAS [j])> 0 THEN BEGIN S: = MAS [i]; mas [i]: = mAS [J]; mAS [J]: = S; end; end; VARS1, S2: STRING; I: Integer; Begin S1: = '???? ??????????????'; s2: = '? ???? ???????? ??????' I: = CompareStr (S1, S2); {i> 0,?.?. S1> s2} IF i <> 0 Then Messagedlg ('?????? ????????!', Mtwarning , [MBOK], 0); END; AnsicompareText compares two strings and no casement. AnsiCompareText (Const S1, S2: String): Integer; Sysutils AnsiCompareStr ('A', 'A') <0 CompareStr ('A', 'A')> 0Function AnsiCompareText (Const S1, S2: String): Integer; AnsilowerCase Transform the string content to lowercase. Function AnsilowerCase (const s: string): string; sysutils var s: string; begin s: = 'myfile.txt'; s: = ansilowercase (s); // s: = 'myfile.txt' Messagedlg (s, mtinformation , [MBOK], 0); END; ANSIUPPERCASE converts the string content to uppercase. Function ANSIUPPERCASE (const s: string): string; s: = 'c: / windows'; {s: = 'c: / windows'} messagedlg (s); {s: = 'c: / windows'} messagedlg (s) , mtinformation, [mbok], 0); AppendStr will connect the given string to the DEST string. Procedure appendstr (var dest: string; const s: string); AssignStr Configuring a memory space to give a string. Procedure appendstr (var P: pstring; const s: string); CompareStr compares two strings. Function CompareStr (Const S1, S2: String): Integer; CompareText compares two strings and no casement. Function CompareText (Const S1, S2: String): Integer; Concat links the column string. Function Concat (S1 [S2, ..., Sn]: string: String; Copy Transfer Site String Part of the String. Function Copy (S: String; Index, Count: Integer): String; delete deletes the subtronom in the given string. Procedure delete (virt s: string; index, count: integer); DisposeStr Releases the space occupied by the string. Procedure DisposeStr (P: pstring); FMTLOADSTR is loaded into a string in the program of resource string table. FmtLoadStr (Ident: Integer; const Args: array of string): string; SysUtilsfunction FmtLoadStr (Ident: Word; const Args: array of const): string; Insert inserting a substring procedure Insert (Source within a string: String , VAR S: String; INDEX: INTEGER; INSERT (Source: String; var s: string; index: integer; system var s: string; begin s: = '??????? ????? ? ??????????. '; INSERT ('! ', S, 8); {s: =' ???????! ?????? ?????? ????. '} Messagedlg (S, MTWARNING, [MboK], 0); END; INTTOHEX turns an integer into hexadecimal. Function INTTOHEX (Value: ": integer: string; INTSTR converts the digital to the word format. Function INTOSTR (Value: longint): string; isvalidIdent discriminates whether the string content is the correct identification word. Function isvalidIdent (const Ident: string): boolean; longens pass back the length of the string. Function Length: Integer; loadStr From the application's executable file into a string resource. Function LoadStr (Ident: Word): String; Sysutils LowerCase converts strings to lowercase. Function LowerCase (const s: string): String; NewStr From the accumulation of a string space. Function newsTr (const s: string): pstring; POS transmission back the position in the string. Function POS (SUBSTR: STRING; S: String): STR turns a value into a string. Procedure Str (x [: width [: decimals]; var s); StrtOINT converts the string into an integer value. Function start (const s: string): longint; startdef will turn the string to a value or a preset value. Function startdef (Const: string; default: long): longint; Uppercase converts strings to uppercase. Function Uppercase: string; sysutils var s: string; begin s: = uppercase ('???????? intel'); {s: = '???????? '} End; VAL converts the string content to a numerical description. Procedure Val (s; var code: integer); system {$ R } {$ r-} var i, code: integer; begin val (edit1.text, i, code); {?????? ?????????? ????? ????????????? edit1.text? ???????? ?????} if code <> 0 THEN {????????? ?????????????? ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ???????? ???????: ' INTOSTR (CODE), MTWARNING, [MBOK], 0) Else {??????? ??????? ??? ??} canvas.textout (20, 20, INTOSTR (SQR (i))); end; ============================ ============ String-handling routines: null-tERMINATED) Unit: systemils =================================================================================================================================================== =================== Stralloc Configure a buffer for a maximum length of Size-1 to null end string function stralloc (size: word): pchar; strbufsize The maximum number of characters that can be stored in the string buffer configured by Stralloc. Strbufsize (s: pchar): cardinal; sysutils Function strbufsize (str: pchar): WRD; STRCAT links two strings and passes back the string. Function Strcat (DEST, SOURCE: PCAR): PCHAR; Strcomp is compared to two strings. Function strcomp (str1, str2: pchar): integer; strcopy copy Source string to DEST. Function Strcopy (DEST, SOURCE: PCHAR): Pchar strdispose Releases a string space. Function strdispose (str: pchar); strcopy copies the Source string to the DEST and passed back to the indicator of the end of the string. Function strecopy (DEST, SURCE: PCHAR): PCHAR; STREND Replies a indicator pointing the end of the string Function Strend (strlcat): pchar; strlcat After connecting the Source string to the DEST string and pass back the word string. Function strlcat (DEST, SOURCE: PCAR; MAXLEN: WORD): PCHAR; STRICOMP Compare two word cascading differences Function Stricomp (str1, str2: pchar): integer; strlcomp compare two strings to the most specified maximum Function strlcomp (Str1, str2: pchar; max: word): integer; strlcopy Copying the specified word to another in another string Function strlcopy (DEST, Source: Pchar; Strlen): Pchar; Strlen The length of the back string. Function strlen (str: pchar): cardinal; strlicomp compares two strings to the specified maximum length. No size. Function strlicomp (str1, str2: pchar; maxlen: word): integer; strlower converts strings to lowercase. Function strlower (str: pchar): pchar; strmove Copy the count of the count, from the Source to the DEST string. Function Strmove (DEST: PCHAR; Count: cardinal): PCHAR STRNEW A string is configured from the accumulation. Function strnew (str: pchar; strpas) Turn the NULL end word 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 Maxlen's fingering element, string from the PASCAL format to NULL end strings. Function strplcopy (DEST: PCHAR; COST SOURCE: STRING; MAXLEN: WORD): PCHAR; STRPOS Biography The position of the Str2 string is the first to appear in STR1. Function Strpos (str1, str2: pchar): PCHAR; STRSCAN back a indicator pointing to the first position of the CHR-element in the STR string. Function strscan (str: pchar; chr: char): PCHAR; STRSCAN Replies a indicator pointing to the location of the CHR-element in the final appearance in the STR substring. Function STRSCAN (STR: PCHAR; Chr: char): pchar; strupper converts the string to uppercase. Function Strupper (str: pchar): pchar; ========================================= Text-file routines unit: system ========================================= == Append opens an existing archive to increase. Procedure append (var f: text); EOLN discriminates if a document is at the end. Function Eoln [(VAR F: Text)]: Boolean; Flush Clears the buffer of the text output file. Procedure flush (var f: text); Read from the file to the list of variables. Typed Files: Procedure Read (F, V1 [, V2, ..., VN]); Text Files: Procedure Read ([VAR F: text;] V1 [, V2, ..., VN]); readln reads information from files to The variables listed and jumped to the next line. Procedure Readln ([VAR f: text;] v1 [, v2, ..., vn]); seekeof discriminates whether it has arrived at the end. Function seekeof [(var f: text)]: boolean; seekeoln discriminates if a file is at the end. Function seekeoln [(VAR f: text)]: boolean; setTextBuf Specifies an I / O buffer to a text file. Procedure setTextBuf (var buf [; size: word]); WRITE writes information within variables to the file. TEXT Files: Procedure Write ([VAR F: Text;] P1 [, P2, ..., PN]); Typed Files: Procedure Write (f, v1 [v2, ... vn]); Writeln Execute the Write program and output a jump line Go to the file. Procedure Writeln ([var f: text;] p1 [, p2, ..., pn]); ============================== =========== Transfer routines unit: system ============================== ========== CHR Remove the character corresponding to the ASCII code. Function chr (x: byte): char; Delphi source task (http://home.kimo.com.tw/bruce0211/) Typing 15 High Transfer Number The highest value. Function high (x); Low transmission back to the minimum number in the range. Function Low (x); ORD is transmitted back to a sequential value corresponding to the order. Function ORD (X): Longint; Round returns a real value to the integer value. Function Round (x: real): longint; Trunc Removes a real value to the integer value. Function trunc (x: real): longint; ======================================== Uned-file routines united file function (united "unit: system ==================================== ==== BlockRead reads one or several records to the BUF variable from the file. Procedure Blockread (var f: file; var buf; count: word [; var result: word]); BlockWrite writes one or several records from a variable. Procedure BlockWrite (var buf; count: word [; var result: word]); =========================== ============================= WinAPI control and message function ---------------- AdjustWindowRect AdjustWindowRectex Given a window styling, calculating the size of the window required to obtain the rectangle of the target customer area =============================================================================================================================================================================== ======================== VB declaration Declare Function AdjustWindower LIB "User32" Alias "AdjustWindower" (LPRECT AS RECT, BYVAL DWSTYLE AS Long, Byval Bmenu As Long) As Long Declare Function AdjustWindowRectEx Lib "user32" Alias "AdjustWindowRectEx" (lpRect As RECT, ByVal dsStyle As Long, ByVal bMenu As Long, ByVal dwEsStyle As Long) As Long description given one kind of window style imports premise, Calculate the number of windows required to get the rectangle of the target client area Return value long, if the execution is successful, returns a non-zero value; if it fails, zero value is returned. Set GetLastError The number of tables of the parameter and the description of LPRECT RECT, which initially contains the required customer area. The function is set to the target window. The rectangular size DWStyle Long, the window styles BMENU long, if the window has a menu, set to True (non-zero) DWESSTYLE LONG, extended window stylus (only available to AdjustWindowerRectex) annotation in call this function Before, get a form of a form with getWindowlong. If the menu occupies a space above two rows, the function cannot correctly calculate the size. If the program uses multi-line headings, you should use getSystemMetrics =========================================== ========================================---------------------------------------- ------------------ VB Declaration Declare Function AnyPopup lib "user32" alias "Anypopup" () AS Long Description Decision The display is available for any pop-up window Return value long, If there is a pop-up menu, return TRUE (non-zero) annotation for this function, the pop-up menu contains all visible tolerance top-level windows, no matter whether the pop-up or overlapping window ========== ============================================================ arrangeiconicWindows is the smallest Chemical Window VB Declaration Declare Function ArrangeiconicWindows LIB "User32" Alias "ArrangeConicWindows" (BYVAL HWND AS long) (BYVAL HWND AS long) (BYVAL HWND AS long) (BYVAL HWND As Long) The minimum sesson window is arranged (used in VB: Used to arrange icons at desktop, Get a handle of a desktop window with a getDesktopWindow function to return a value of a value of LONG, a height of the icon row; if it fails, zero is returned. Set the type of GetLasTerror parameter table and the handle of HWnd Long, Father's Window This function can also be used to include the custom control of the icon-type sub-window ================================ ======================= AttachthreadInput connection thread input function BegindeferWindowPOS boot to build a series of new window 囗 positions BringWindowtotop takes the specified window to the window 囗 list Top Cascadewindows Returns the CHILDWINDOWFROMPOINT in a laminated manner to return to the parent window The handle of the first child window containing the specified point. ClientToscreen judges the screen coordinate closewindow, which is represented by the customer zone coordinate, minimizes the specified window. CopyRect Rectangular Content Copy DEFERWINDOWPOS This function Specifies a new window 囗 DestroyWindow Clear the specified window 囗 DrawanImatedRects depicts a series of dynamic rectangular enableWindow specified in the window to allow or disable all mouse and keyboard Enter EnddeferWindowPOS At the same time, the location and status of all the windows specified when DeferWindowPos are updated and the state enumChildWindows is a specified parent window. ENUMTHREADWINDOWS Enumerates All parent windows in EqualRect in the list of specified tasks, EqualRect, two rectangular structures, whether the two rectangular structures are the same, the first-class window, the first-class window, the first-level window, FindWindowEx in the window Look for the first sub-window 囗 ==================================================================================================================================================================================================================================================================================== ---------------------------- Procedure TFORM1.BUTTON1CLICK (Sender: Tobject); Begin Form2.Show; Form1.Bringtofront; Timer1.Interval : = GetCareTBlinkTime; Timer1.enabled: = not timer1.enabled; Procedure tform1.timer1timer (sender: TOBJECT); Begin FlashWindow (Form2.Handle, True); End; ============================ == GetActiveWindow Get the handle of the active window GetCapture Gets a handle of a window, which is located in the current input thread, and has a copy of the mouse capture (the mouse activity is received by it) GetClassInfo obtains a copy of the WNDCLASS structure (or WNDCLASSEX structure). The information related to the specified class GetClasslong gets a long-variable entry getClassName gets getClassName gets the class get Class GetClassword to the window. A integer variable getClientRect Return to the specified window stunned customer area rectangular size getDesktopWindow Get a representative A window of the entire screen (Desktop Window) handle getFOCUS Get the handle of the window of the input focus GetForeGroup getting the handle of the front desktop GetLastactivePopup gets the most recently activated pop-ups in a given father-activated pop-up window GetLastError For previously called API functions, use this function to extend error message GetParent judges the parent window of the specified window, GetTopWindow, search for internal windows, and finds the handle GetUpdateRect that is subjected to the header of the specified window, gets a rectangle, which describes the part of the specified window that needs to be updated === ====================================================== GetWindow get a window囗 手柄, this window has a specific relationship with a source window -------------------------------- -------------- Procedure TFORM1.TIMER1TIMER (Sender: Tobject); var s: array [0..29999] of char; h: h: h: h: h: = getWindow (Handle, GW_OWNER ); // getwindow Take a handle of a window, which has a specific relationship with a source window GetWindowText (h, s, 300); // getWindowText takes a form title (CAPTION) text, or control content edit1 .text: = INTOSTR (H); label1.caption: = S; end; ================================= ================ getWindowContexthelpid acquires the help scene ID getWindowl from the window 囗 GetWindowl from the structure of the specified window GetWindowPlacement GetwindowPlacement GetWindowRect The range of the entire window, the border of the window, the title bar, scrolling Both of the strips and men, etc. are in this rectangle ========================================= ======= GetWindowText acquires a form of a form, or a control content ------------------------ Procedure TFORM1.TIMER1TIMER (Sender: TOBJECT); var s: array [0..29999] of char; h: integer; begin h: = getwindow (handle, gw_owner); // getWindow Take a window 囗 handle, the window is with some source window Specific relationship getWindowText (h, s, 300); // getWindowText takes a form header (CAPTION) text, or control content edit1.text: = INTOSTR (H); label1.caption: = s; end; === ========================= GetWindowTextLength Survey window 囗 Title text or control content length getWindowWord gets the information of the specified window hunger structure Inflaterect increases or decreases A rectangular size INTERSECTRECT This function loads a rectangle in LPDestRect, which is LPSRC1RECT and LPSRC2RECT two rectangular intersections inValidateRect blocking all or part of the area ischild's full or part of the area ischild to determine if a window is another window. Or members of the ISICIONIC judgment window that minimizes ISRECTEMPTY to determine if a rectangle is empty ISWINDOW to determine if a window 囗 handle is effective IsWindowNableD judgment window 囗 is active IsWindowunicowUnic ODE determines whether a window is a Unicode window. This means that the window scorpion receives unicode text iswindowVisible to all text-based messages. Is it visual i om 囗 囗 化 化 化 化 消 消 消 消 消 消 消 囗 囗 囗 囗 囗 囗 囗 囗 囗 囗 囗 囗Customer area coordinate system of a window MoveWindow changes the location and size of the specified window and the size of OffsetRect Let the rectangle move up OpenICON to restore a minimized program, and activate the PtinRect to determine whether the specified point is located in the rectangular internal RedrawWindow heavy or part Window ReleaseCapture is the current application release the mouse capture ScreenToClient Judgment screen on a specified point of the client area coordinate scrollwindow Scroll Window Customer Area's All or some of the ScrollWindowEx, according to the additional option, the Scroll Window Customer Area's All or SeetActiveWindow activation specified Window Tight SetCapture Sets the Mouse Capture to the Specified Window SetClasslong Sets a long variable entry setClassword to the window stupid Sets SetFocusAPI Set the input focus to the specified window. If necessary, activate the window stun setForegroundWindow Set the front-end window of the window to the system setparent Specifies the new parent setRect of a window. SetRectempty Set the rectangular SetRectempty Set the rectangle to set the SETWINDOWCONTEXTHELPID to set the help scene for the specified window. (Context) ID Setwindowl Settings Information SetWindowPlacement Settings Window Status and Location Information in the Window Structure SetWindowPOS Specifies a new location and status setWindowText Settings Window Title text or control content setWindowWord Sets or hides all pop-ups of the specified window stunned in the window 囗 囗 全 弹 弹 弹 弹 弹The visibility of the control window show SHOWWINDOWASYNC with ShowWindow Similar SubtractRect Load Rectangle Lprcdst, which is the result of subtract LPRCSRC2 in rectangular LPRCSRC1 TileWindows Arranged in tile order UnionRect A LPDestRect destination, which is the result of LPSRC1RECT and LPSRC2RECT united UpdateWindow to Immediately update all or part of the customer area of the window. Handle. Ignore the mask, hidden and transparent window ========================================== ============ Hardware and system functions ---------------- ActivateKeyboardLayout activates a new keyboard layout. Keyboard layout defines the position and meaning of the button on a physical keyboard --------------------------- VB Declaration Declare Function ActivateKeyboardLayout LIB "User32" Alias "ActivateKeyboardLayout" (Byval Flags As Long) AS Long Description Activate a new keyboard layout. The keyboard layout defines the key to the position and the meaning of the key on a physical keyboard, such as execution, returns the handle of the previous keyboard layout; zero means failure. Set the GetLasTerror parameter type and description HKL Long, specify a handle of a keyboard layout. This layout is loaded with the LoadKeyboardLayout or getKeyboardLayoutList function. You can also activate the next loaded layout with the HKL_NEXT constant; or use the HKL_PREV to load the previous layout Flags long, move the specified keyboard to the beginning of the internal keyboard layout list ================================= ==================== BEEP is used to generate a simple sound Chartooem to convert a string from ansi character set to OEM character set CLIPCURSOR to limit the pointer to the specified area ConvertDefaultLocale A special place identifier converts into a real place ID CREATECARET Create an insert (cursor) based on the specified information, and select it as the default insert destroycaret clear (destroy) an insert enumcalendarinfo enumeration in the specified window. Specifies the Calendar Information EnumdateFormats available in the Local Environment Enumerates the long, short-term format EnumsystemCodepages enumeration system installed or supported in the specified "Local" settings Enumerate enumeration system installed or supported "Place" "Setting EnumTimeFormats Enumerates a specified place Application time format EXITWINDOWSEX exits Windows, and restarts ExpandenvironmentStringsTrings Translate FREEENVIRONMENTSTRINGS Translation Specifies the ANSI code page for the currently effective ANSI code page with specific options. GetAsyncKeyState determines the function call When the VCRETBLINKTIME determines that the blinking frequency of the insertion target GetCareTPOS determines the current location of the insertion. GetClipCursor obtains a rectangle, which is used to describe the clipping area specified by the mouse pointer getCommandline to get the current command line buffer. A pointer getComputername acquired the name of this computer getCPinfo to get information about the specified code page GetCurrencyFormat for the specified "place" setting, format a digital getCursor to get the currently selected mouse pointer according to the currency format. GetCursorpos gets the current location of the mouse pointer getDDateformat for the specified "local" format, format the GetDoubleClickTime to determine the interval between the two mouse clicks to double-click the time. GetEnvironmentStrings contain the current environment string. A memory block allocation and returns a handle GetENVIRONMENTVARIABLE obtains a value of a environment variable GetInputState to determine if there is any mouse or keyboard event getkbcodepage that is predetermined (wait for processing), and the two functions are completely the same GetKeyboardLayout to obtain a handle, description designation The application's keyboard layout getKeyboardLayoutList Get a list of all keyboard layouts for the system GetKeyboardLayoutName gets the name of the current active keyboard layout getKeyboardState gets the current state GetKeyboardType on the keyboard. GetKeyNameText is given the information about the keyboard. Under the premise of the code, it is determined that the key name getKeyState is a processed button. When you enter information in the last time, it is judged that the state GetLastError specified the virtual key for the previously called the API function, and uses this function to obtain an extension error message getLocaleInfo acquisition and designated "place "Related information GetLocalTime acquires local dates and time GetNumberformat for specified "places", format a number Getoemcp in a specific format to determine the Windows code page GetQueUStatus to the OEM and ANSI characters in the OEM and ASI characters. Message Type GetsysColor Judgment Specifies Windows Display Passage Color GetSystemDefaultLAGID Getting System Default Language ID GetSystemDefaultLcid gets the current default system "Local" getSystemInfo get information related to the underlying hardware platform GetSystemMetrics Returns the information related to the Windows environment gets getSystemTime to get the current system time. This time is "synergistic world time" (ie UTC, also called GMT) format getsystemTIMEADJUSTMENT to make the internal system clock with one External clock signal Source Synchronization GetThreadLocale Location ID GetTickCount to get the current length (milliseconds) getTime (millisecond) getTime (millisecond) getTimeFormat, since Windows startup, formatted a system time in a specific format GetTimeZoneInformation obtains information about the system time zone settings GetUserDefaultLangId gets the default language ID GetUserDefaultlcid gets the current user's default "place" setting getUserName gets the current user's name GetVersion to determine the current Run Windows and DOS version GetVersionEx acquire the platform and operating system Version information hidecaret Hide insert (cursor) isvalidCodePage to determine if a code page is valid, if the keyboard action loadKeyboardLayout loads, the keyboard action loadKeyboardLayout loads a keyboard to load mappvirtualKey, execute Different scan codes and characters are converted MapVirtualKeyEx to perform different scan code and character conversion messagebeep play a system sound based on the specified mapping type. The allocation scheme of the system sound is the mouse_event to simulate a mouse event OemKeyscan to determine the scan code of an ASCII character in the OEM character set and the SHIFT key status OEMTOCHAR converts a string of the OEM character set to ansi character set. SetCareTBlinkTime Specifies the Blinking Frequency SetCareTPOS Specifying the Pixcurs Port SetComputerName Set the new computer name setCursor Set the specified mouse pointer to the current pointer setCursorpos Setting Pointer position SetDoubleClickTime Settings Continuous Two mouse clicks It is considered that the interval of double-clicking the event. SetEnvironmentvariable sets an environment variable to the specified value setKeyboardState sets each virtual key. SitLocaleInfo changes on the keyboard to change the user "local" setting information. SetLocalTime Sets Current Route Time SetsysColors Settings Specify Windows Maxi Show Colors SetsystemCursor to change any standard system pointer SetSystemTime Settings Current System Time SetsystemTimeAdJustment Timed Add a calibration value to make the internal system clock with an external clock signal source Synchronization setthreadLocale Setting the location for the current thread Settings Settings System Time zone information showcaret Showcaret displays the insert (cursor) Showcursor control mouse The visibility of the pointer SwapMouseButton decides whether to switch the mouse button SystemParametersInfo Gets and Sets the number of Windows system SYSTEMTIMTOTZSPECICLOCALTIME converts system time to local time toascii Depending on the current scan code and keyboard information, convert a virtual key to ASCII character TOUNICODE according to the current scan code and keyboard information, will be virtualized according to the current scan code and keyboard information Key Convert into Unicode Character UnloadKeyboardLayout Uninstalls the specified keyboard layout VKKEYSCAN to set a ASCII character for the Windows characters, determine the state of the virtual key code and the Shift key =================== ================================== Menu function -------------- - Appendmenu Add a menu item in the specified menu ------------------------------------- - VB Declaration Declare Function Appendmenu LIB "User32" Alias "Appendmenua" (BYVAL WFLAGS AS Long, Byval WidnewItem As Long, BYVAL LPNEWITEM AS ANY) AS Long Description Add a menu item in the specified menu Return Value LONG Non-zero means success, zero means failure. Setting the GetLasTerror parameter type and description HMENU Long, menu handle WFLAGS long, the menu constant flag definition table in the ModifyMenu function, list all constant WidnewItem Long, specify the new command ID of the menu entry . If the MF_POPUP field is specified in the WFLAGS number, this should be a handle of a pop-up menu LPNewItem String (corresponding VB declaration), if the MF_STRING flag is specified in the WFLAGS number, which represents in the menu Set string. If the MF_bitmap flag is set, this represents a long type variable, which contains a bitmap sector. If MF_OWNERDRAW is set, this value will be included in the DrawItemStruct and MeasureItemstruct structure, and it is sent by Windows when the entry needs to be heavy. Note Declare Function Appendmenu & Lib "User32" Alias "Appendmenua" (Byval WFLAGS As Long, Byval WidnewItem As String) ================= ======================== CheckMenuItem check or revoke the check specified menu entry CheckMenuradioItem specifies that a menu entry is subselected as "radio" project CreateMenu create a new menu CreatePopupMenu create an empty pop-up menu DeleteMenu delete the specified menu entry DestroyMenu delete the specified menu DrawMenuBar specified window imports redraw the menu EnableMenuItem enable or disable specific menu items GetMenu made window imports in a menu handle GetMenuCheckMarkDimensions return Size GetMenuContexthelpid Get MenuContexthelpid Gets a menu to help which entries in the GetMenudefaultItem judgment menu are the default entry GetMenuItemCount Return to the number of entries (menu items) GetMenuItemID Returns the entry to the menu ID GetMenuItemInfo Accommined (Receive) Specific information related to a menu entry GetMenuItemRect on a rectangular menu entry screen coordinate information getMenustate getting information related to the specified menu entry status GetMenustring gets the specified menu entry string GE TSUBMenu gets a handle of a pop-up menu, which is located in the menu GetSystemMenu gets the HiliteMenuiteM control of the system menu of the specified window HiliteMenuItem Control Top Menu entries Insert a menu entry at the specified location of the menu, and puts other entries down to move the insertMenuItem as needed to insert a new menu entries ISMENU judgment designation Whether the handle is a menu to load a menu load from the specified module or application instance LoadMenuIndirect load a menu MenuItemFromPoint to determine which menu entry contains a specified point MODIFYMENU to change the menu entry RemoveMenu Removes the specified menu entry SetMenu Settings Window Menu SetMenuContextHelpid Setting up a menu To set a menu entry to the default entry SetMenuItemBitmaps Set a specific bitmap, which is used in the specified menu entry, replacing the standard Select Symbol () SetMenuiteminfo For a menu entry Settings TRACKPOPUPMENU Display a poppopuppopUpMenuex with TrackPopUpMenu, but it provides additional functions Following out below the Type of Menu Functions Definition Menuiteminfo This structure contains the menu entry information TPMPARAMS This structure is used for TRACKPOPUPMENUEX functions to support additional function ================= ========================================= Draw function -------- Abortpath Abandoned Specifies all paths in the device scene. Also canceled the creation of any path currently ongoing ------------------------------------- ------------------------------- VB Declaration Declare Function AbortPath LIB "GDI32" Alias "AbortPath" (Byval HDC As Long AS long description Abandon all paths in the specified device scenario. It is also canceled that the creation of any paths currently ongoing, and the non-zero means success, and zero means fail. Setting the GetLasTerror parameter type and description HDC Long, device scene ===================================== = Anglearc Painting with a connection arc --------------------------- VB Declaration Declare Function Anglearc LIB "GDI32" Alias "Anglearc (Byval HDC As Long, Byval X As Long, Byval Y As Long, Byval Double, Byval EsWeepangle As Double) AS Long Description A line of connection arc is drawn, and the test is annotated. Non-zero means successful, zero indicates failure 叁 number table 叁 type and description HDC Long, to be in the device scene X, Y long, a circular center point coordinate of arc DWRADIUS Long, round radius ESTARTANGLE DOUBLE Specifies, and should be a single precision (SINGLE) instead of double precision. The corresponding function declaration is: Declare Function Anglearc & LIB "GDI32" (Byval HDC As Long, Byval X As Long, Byval Y, byval Estartangle As Single, Byval EswePangle As Single). My understanding: The function declared in this article is copied to the VB's API text viewer. The declaration from me came from my entry, and I don't know who is wrong. Description of the number table, press the data type in the declaration replication in the VB's API text viewer. Please note ============================================= ======= Arc Painting a Arc BeginPath Start a Path Branch Canceldc Cancel the long-term drawing in another thread CHORD Draw a string closeenhmetafile closes the specified enhanced element file device scene and will create new primitives When the file returns a handle Closefigure, when you depict it to a path, turn off the currently open graphical closemetafile closes the specified primitive module device scene and return a handle to the newly created element file. Copyenhmetafile makes a copy of the specified enhanced element file (copy) CopyMetafile creates a copy of the specified (standard) element file CreatebrushDirect creates a brush createDibpatternbrush on a logbrush data structure to create a bitmap-independent bitmap Brush to specify a brush style (pattern) CREANHMETAFILE Create a enhanced element file device Scene CreateHatchBrush Creating a brush CreateMetafile with shadow pattern Creating a chamfer file device Scene CreatePatternBrush Create a bitmap specifying a brush pattern brush Createpen Create a brush CreatepenIndirecture with the specified style, width, and color Creating a brush CreateSolidbrush based on the specified Logpen structure Creating a brush DELETEENHMETAFILE Deleting the specified enhancement element DELETEMETAFILE Delete the specified element file DeleteObject Delete the GDI object, All system resources like use are released by DrawEdge with a specified style to draw a rectangular border DrawScape Call (ESCAPE) function to send data directly to the display device driver DrawFOCUSRECT draw a focus rectangular DrawFraMEControl depicts a standard control DrawState as an image Or the drawing operation Application Ellipse depicts an ellipse, stops a path ENUMENHMETAFILE to define a path ENUMENHMETAFILE by the specified rectangle to list the enhanced element files, enumeration in which the ENUMMETAFILE is a standard Windows element File Enumeration Separate Diming Document Record Enumjects Enumeration You can use the brush and brush Extcreatepen that can be used in the specified device scene, create an extension brush (decorative or geometric) extfloodfill in the specified device scenario, populate a region with the currently selected brush FillPath Close any open graphics in the path, and fill the FillRect with the current brush FillRect with a specified brush to convert all the curves in a path into line segment floodfill with the currently selected brush to populate a zone FrameRect in the specified device scenario With the specified brush, a border GDICOMMENT with a specified brush adds a comment information for the specified enhanced element file device Scenario Add a comment message. Drawing commands can enter the queue When the GetarcDirection is painted, it is judged that the currently used drawing direction getBKColor acquires the current background color GetBkmode for the specified device scene. Get the current background fill mode Getbrushorgex Judgment The currently selected brush starting point GetCurrentObject in the specified device scene GetCurrentObject Get the specified type. Current Selected Password GetCurrentPositionEx acquires the current brush position getnhmetafile in the specified device scenario GetenhmetAfile acquired a reinforced element file in the disk file GetenhmetafileBits copies the specified enhancement element file to a memory buffer Zone GetENHMETAFILEDESCRIPTION Returns the description of a enhanced element file GetenhmetafileHeader gets the element file header of the enhanced element file getnhmetafilepaletteenTries gets all or part of the palette GetMetAfile to enable in a disk file. Module file handle GetMetAfileBitsex Copy the specified element file to a memory buffer getMiterlimit to get the slope limit of the device scene (MITER) Setting GetNearestColor obtains a solid color GetObjectApi that is closest to the specified color according to the display capabilities of the device. A structure like a description GetObjectType determines that the type getPath obtained by the GDI object referenced by the specified handle acquires a series of data GetPixel defined for the current path in the specified device scenario to obtain a pixel RGB value GetPolyFillMode for the specified device scene, get the polygon padding mode getRop2 for the specified Equipment scenario, get the current drawing mode getStockObject get a solid-free (stock) getSyscolorbrush to get a brush for any standard system color GetWinMetafileBits converts a enhanced element file into a standard Windows element file by popping data for standard primitive files in a buffer.