home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / pascal / 8503 < prev    next >
Encoding:
Internet Message Format  |  1993-01-25  |  1.1 KB

  1. Path: sparky!uunet!mcsun!uknet!almac!mike.dickson
  2. From: mike.dickson@almac.co.uk (Mike Dickson)
  3. Newsgroups: comp.lang.pascal
  4. Subject: Re: Avoiding system error
  5. Message-ID: <821.548.uupcb@almac.co.uk>
  6. Date: 23 Jan 93 17:04:00 GMT
  7. Reply-To: mike.dickson@almac.co.uk (Mike Dickson)
  8. Organization: Almac BBS Ltd. +44 (0)324 665371
  9. Lines: 27
  10.  
  11. PP..try the following function (must have a USES DOS )
  12. PP..    Function Exist (aFile:String):Boolean;
  13. PP..    var Sr:SearchRec;
  14. PP..    begin
  15. PP..       FindFirst(aFile,ANYFILE-DIRECTORY-VOLUMEID,Sr);
  16. PP..       Exist:=DosError =0
  17. PP..    end;
  18.  
  19. One small correction, possibly; instead of using FindFirst you could use
  20.  
  21. FUNCTION FileExists (Filename : String) : Boolean;
  22. var
  23.    Attr : Word;
  24.    f    : file;
  25. begin
  26.    Assign (f, Filename);
  27.    GetFAttr(f, attr);
  28.    FileExists := (DOSError = 0);
  29. end;
  30.  
  31. The reason for this is that there is a bug in the OS/2 Service Pak that
  32. prevents some instances of FindFirst from working.
  33.  
  34. /\/\ | |< |.                                     mike.dickson@almac.co.uk
  35. ---
  36.  . SLMR 2.1a . Sex is better than logic, but I can't prove it.
  37.      
  38.