next up previous contents index
Next: FindNext Up: Functions and Procedures Previous: FindClose

FindFirst

   

Declaration:

Procedure FindFirst (const Path: pathstr; Attr: word; var F: SearchRec) ;

Description:

FindFirst searches the file specified in Path, checks the atrributes specified in Attr. 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.

Errors:

Errors are reported in DosError.

See also:

FindNext, FindClose

Example
Program Example7;
uses Dos;

{ Program to demonstrate the FindFirst and FindNext function. }

var
  Dir : SearchRec;
begin
  FindFirst('*.*',$20,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.



Michael Van Canneyt
Thu Sep 10 13:59:33 CEST 1998