home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / pascal / 7435 < prev    next >
Encoding:
Internet Message Format  |  1992-12-13  |  1.6 KB

  1. Path: sparky!uunet!psinntp!newton.hartwick.edu!wisanr
  2. From: wisanr@newton.hartwick.edu
  3. Newsgroups: comp.lang.pascal
  4. Subject: TP's reset on read-only files
  5. Message-ID: <1992Dec12.214246.50@newton.hartwick.edu>
  6. Date: 12 Dec 92 21:42:46 -0500
  7. Organization: HARTWICK COLLEGE
  8. Lines: 27
  9.  
  10.  
  11. I've been astonished to discover that TP's reset procedure can't open a
  12. read-only file ex@|cept as a text file.  This appears to be true of
  13. every version since TP1.  If it weren't clearly documented I'd call it a bug:
  14. reset opens a text file for input and any other kind of file for
  15. input and output.  In consequence, DOS will reject an attempt to reset a file
  16. with attribute read-only.
  17.  
  18. The only work-around I've found is to change the attribute, open and
  19. read the file, close it, and put it back to read-only.  I don't like it because
  20. a program that stops abnormally might close the file, but it
  21. will surely not restore the attribute.  
  22. TP7 comes with the source code for the run-time library, and it's
  23. perfectly clear there in FCTL.ASM.  TP opens the file with the standard
  24. file-handle DOS call: INT 21h with AH=3Ch and AL=2.  AL=2 opens for both
  25. read and write access.  AL=0 would open for read only and AL=1 for write
  26. only.  The value for AL is taken from a typed constant in SYSTEM.PAS
  27.  
  28. Ideally, I'd like to add a new procedure, say reset2read which would load AL=0
  29. in FCTL.ASM, but I'm diffident about tryingl that.  The
  30. trouble is that you'd have to insert a new typed constant and a new procedure
  31. declaration in SYSTEM.PAS, and the lists of declarations there
  32. is peppered with warnings not to change anything because the compiler
  33. depends on their exact order.
  34.  
  35. Now, what?
  36.  
  37.