FindFirst procedure
Start search for one or more files.
Declaration
procedure FindFirst(const path: PathStr; attr: Word; var f: SearchRec)Description
FindFirst searches the file specified in
Path. Normal files,
as well as all special files which have the attributes specified in
Attr will be returned.
It returns a SearchRec record for further searching in F.
Path can contain the wildcard characters ? (matches any single
character) and * (matches 0 ore more arbitrary characters). In this
case FindFirst will return the first file which matches the specified
criteria.
If DosError is different from zero, no file(s) matching the criteria
was(were) found.
On the EMX target, you cannot issue two different
FindFirst calls. That is,
you must close any previous search operation with FindClose before
starting a new one. Failure to do so will end in a Run-Time Error 6
(Invalid file handle)
Errors
Errors are reported in DosError.
See also
Example: ex7
Program Example7;
uses Dos;
{ Program to demonstrate the FindFirst and FindNext function. }
var
Dir : SearchRec;
begin
FindFirst('*.*',archive,Dir);
WriteLn('FileName'+Space(32),'FileSize':9);
while (DosError=0) do
begin
Writeln(Dir.Name+Space(40-Length(Dir.Name)),Dir.Size:9);
FindNext(Dir);
end;
FindClose(Dir);
end.An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
