home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / pascal / 7641 < prev    next >
Encoding:
Internet Message Format  |  1992-12-22  |  2.8 KB

  1. Path: sparky!uunet!haven.umd.edu!mimsy!nmrdc1!frmug!lill!vanney.raphael
  2. From: vanney.raphael@lill.frmug.fr.mugnet.org (Vanney Raphael)
  3. Newsgroups: comp.lang.pascal
  4. Subject: RE: TURBO PASCAL FUNC. ER
  5. Message-ID: <965.6.uupcb@lill.frmug.fr.mugnet.org>
  6. Date: 20 Dec 92 19:13:00 GMT
  7. Reply-To: vanney.raphael@lill.frmug.fr.mugnet.org (Vanney Raphael)
  8. Organization: Li'LL BBS - Paris, France
  9. Lines: 93
  10.  
  11.  
  12.  -=> Quoting Thomas Rose to All <=-
  13.  
  14.  TR> From: toddy@uni-paderborn.de (Thomas Rose)
  15.  TR> Newsgroups: comp.lang.pascal
  16.  TR> Subject: Turbo Pascal Func. Erease
  17.  TR> Date: 2 Dec 92 15:59:32 GMT
  18.  TR> Organization: Uni-GH Paderborn, Germany
  19.  
  20.  TR> Hi, I have a problem with Turbo-Pascal 6.0 and the Procedure
  21. Erase(f).
  22.  TR> The following little program shoud demontrate it:
  23.  
  24.  TR> program test;
  25.  
  26.  TR> uses dos;
  27.  
  28.  TR> var f   : file;
  29.  TR> err : word;
  30.  TR> Begin
  31.  TR> assign(f,'test.dat');
  32.  TR> erase(f);
  33.  
  34.  TR> err := ioresult;
  35.  
  36.  TR> repeat until keypressed;
  37.  TR> erase(f);
  38.  TR> err := ioresult;
  39.  TR> end.
  40.  
  41.  TR> When you test it with a write-protected disk, then you'll get first
  42.  TR> the errornumber 150:'Disk is write-protected', but when you try it
  43.  TR> once again, then the next errornumber is 2:'File not found'.
  44.  
  45.  TR> I need this Function for a program which deletes all files on a
  46. disk.
  47.  TR> But when the disk is write-protected and i ask the User to remove
  48. it,
  49.  TR> i have to try it once again. But then, the file will not be found. 
  50.  
  51. Huh ? Seems like your disk cache has got a problem handling this : I
  52. never
  53. encountered such a problem ;-)
  54.  
  55.  TR> Then another problem: is it possible to open a file, which has the
  56.  TR> attributes 'read-only' ?? I tryed it with : 
  57.  TR> program test;
  58.  TR> var f : file;
  59.  TR> begin
  60.  TR> assign(f,'io.sys');
  61.  TR> reset(f);
  62.  TR> writeln(ioresult:3);
  63.  TR> end.
  64.  
  65.  TR> but i got the errornumber 5:'access denied'
  66.  
  67. Hi !
  68. I have no satisfying answer to your first question, but here is how to
  69. open a file with R/O, Hiden and/or System attributes :
  70.  
  71. Uses DOS ;
  72. Var  f    : Text ;
  73. Begin
  74.      Assign(f, 'IO.SYS') ;
  75.      SetFAttr(f, 0) ;         { Don't expect this to work with
  76. directories
  77.                                 nor volume id }
  78.      { Here, take a look at DOSError }
  79.      ReSet(f) ;
  80.      { Check IOResult }
  81.      .
  82.      .
  83.      .
  84.      Close(f) ;
  85.      { Eventually restore original file attributes... }
  86. End ;
  87.  
  88.  TR> Please reply to duep@uni-paderborn.de
  89.  
  90.  TR> thanks and goodby,  Juergen Duepjohann
  91.  
  92.  
  93.  TR> -!- GEcho 1.00
  94.  TR>  ! Origin: Li'LL BBS - Paris France - (33-1) 43.07.40.97 (2:320/7)
  95.  
  96.                                              Raphael.
  97.  
  98.  
  99. ... Sorry, the Dog ate my Blue Wave packet.
  100. --- FMail 0.92
  101.  * Origin: ICEBERG - La Garenne * FRANCE * Tel:(33)-1-47699261
  102. (2:320/1.0)
  103.                                                                                                                           
  104.