Added examples 38-43

This commit is contained in:
michael 1999-05-14 22:02:23 +00:00
parent 34dc9f8bc6
commit 4571b76759
8 changed files with 123 additions and 1 deletions

View File

@ -35,7 +35,7 @@ endif
OBJECTS=ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 ex10 ex11 ex12\
ex13 ex14 ex15 ex16 ex17 ex18 ex19 ex20 ex21 ex22 ex23 ex24\
ex25 ex26 ex27 ex28 ex29 ex30 ex31 ex32 ex33 ex34 ex35 ex36\
ex37
ex37 ex38 ex39 ex40 ex41 ex42 ex43
TEXOBJECTS=$(addsuffix .tex, $(OBJECTS))

View File

@ -37,3 +37,9 @@ ex34.pp contains an example of the ExtractFileName function.
ex35.pp contains an example of the ExtractRelativePath function.
ex36.pp contains an example of the FileAge function.
ex37.pp contains an example of the FileCreate function.
exex38.pp contains an example of the FileExists function.
ex39.pp contains an example of the FileGetDate function.
ex40.pp contains an example of the FileGetAttr function.
ex41.pp contains an example of the FileSearch function.
ex42.pp contains an example of the FileSetAttr function.
ex43.pp contains an example of the FindFirst function.

10
docs/sysutex/ex38.pp Normal file
View File

@ -0,0 +1,10 @@
Program Example38;
{ This program demonstrates the FileExists function }
Uses sysutils;
Begin
If FileExists(ParamStr(0)) Then
Writeln ('All is well, I seem to exist.');
End.

15
docs/sysutex/ex39.pp Normal file
View File

@ -0,0 +1,15 @@
Program Example39;
{ This program demonstrates the FileGetDate function }
Uses sysutils;
Var F,D : Longint;
Begin
F:=FileCreate('test.dat');
D:=FileGetDate(D);
Writeln ('File crerated on ',DateTimeToStr(FileDateToDateTime(D)));
FileClose(F);
DeleteFile('test.dat');
End.

38
docs/sysutex/ex40.pp Normal file
View File

@ -0,0 +1,38 @@
Program Example40;
{ This program demonstrates the FileGetAttr function }
Uses sysutils;
Procedure Testit (Name : String);
Var F : Longint;
Begin
F:=FileGetAttr(Name);
If F<>-1 then
begin
Writeln ('Testing : ',Name);
If (F and faReadOnly)<>0 then
Writeln ('File is ReadOnly');
If (F and faHidden)<>0 then
Writeln ('File is hidden');
If (F and faSysFile)<>0 then
Writeln ('File is a system file');
If (F and faVolumeID)<>0 then
Writeln ('File is a disk label');
If (F and faArchive)<>0 then
Writeln ('File is artchive file');
If (F and faDirectory)<>0 then
Writeln ('File is a directory');
end
else
Writeln ('Error reading attribites of ',Name);
end;
begin
testit ('ex40.pp');
testit (ParamStr(0));
testit ('.');
testit ('/');
End.

18
docs/sysutex/ex41.pp Normal file
View File

@ -0,0 +1,18 @@
Program Example41;
{ Program to demonstrate the FileSearch function. }
Uses Sysutils;
Const
{$ifdef linux}
FN = 'find';
P = '.:/bin:/usr/bin';
{$else}
FN = 'find.exe';
P = 'c:\dos;c:\windows;c:\windows\system;c:\windows\system32');
{$endif}
begin
Writeln ('find is in : ',FileSearch (FN,P));
end.

12
docs/sysutex/ex42.pp Normal file
View File

@ -0,0 +1,12 @@
Program Example42;
{ This program demonstrates the FileSetAttr function }
Uses sysutils;
Begin
If FileSetAttr ('ex40.pp',faReadOnly or faHidden)=0 then
Writeln ('Successfully made file hidden and read-only.')
else
Writeln ('Coulnd''t make file hidden and read-only.');
End.

23
docs/sysutex/ex43.pp Normal file
View File

@ -0,0 +1,23 @@
Program Example43;
{ This program demonstrates the FindFirst function }
Uses sysutils;
Var Info : TSearchRec;
Count : Longint;
Begin
Count:=0;
If FindFirst ('*.pp',faAnyFile,Info)=0 then
begin
Repeat
Inc(Count);
With Info do
Writeln (Name:40,Size:15);
Until FindNext(info)<>0;
end;
FindClose(Info);
Writeln ('Finished search. Found ',Count,' matches');
End.