home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / PROG / PASCAL / MISCTI10.ZIP / TI191.ASC < prev    next >
Encoding:
Text File  |  1988-04-18  |  2.5 KB  |  75 lines

  1. PRODUCT : TURBO PASCAL     NUMBER : 191
  2. VERSION : 3.0xx
  3.      OS : PC-DOS, MS-DOS
  4.    DATE : March 13, 1986
  5.  
  6.   TITLE : ADVANCED FILE HANDLING
  7.  
  8. The  following  information is presented for  advanced  users  of 
  9. Turbo Pascal using MS-DOS or PC-DOS operating systems.
  10.  
  11. Turbo  Pascal uses MS-DOS file handles to open files.    Function 
  12. call  3DH  is used.   One of the parameters to this call  is  the 
  13. "open  mode," which provides DOS with information about  the  way 
  14. you  intend  to  access the file and what access to  allow  other 
  15. processes (in a networking or future multitasking environment).  
  16.  
  17. Turbo  Pascal  normally  uses  an open  mode  byte  of  2,  which 
  18. designates   Compatibility   Mode  with  Read/Write  Access   and 
  19. Inheritance  by child processes.  By changing the value  of  this 
  20. byte  to  0,  you may open Read-only files.   There may be  other 
  21. applications for this, especially in a network environment.
  22.  
  23. Open mode byte for Reset & Rewrite (PC-DOS)
  24.                                                      
  25.     TURBO.COM    CSEG:$248D
  26.     TURBO-87.COM CSEG:$1F3C
  27.     TURBOBCD.COM CSEG:$2393
  28.  
  29. Open mode byte for Reset & Rewrite (MS-DOS)
  30.  
  31.     TURBO.COM    CSEG:$2182
  32.     TURBO-87.COM CSEG:$1C31
  33.     TURBOBCD.COM CSEG:$2088
  34.  
  35. The  best  way to use this information is to create  an  absolute 
  36. variable pointing to the byte, for example:
  37.  
  38.   var OpenModeByte: byte absolute CSeg:$248D;  (TURBO.COM PC-DOS)
  39.  
  40. For additional safety, make sure that the value of the byte being 
  41. changed  is actually 2 before changing it.   Remember,  change it 
  42. back to 2 if you intend to do normal file opening intermixed with 
  43. opening  of  Read-only  or  shared  files.   Information  on  the 
  44. different  attributes  can  be found in  the  DOS  3.1  Technical 
  45. Reference Manual.
  46.  
  47.  
  48. { Using TURBO.COM version 3.00B }
  49.  
  50. var OpenModeByte: byte absolute CSeg:$248D;  (TURBO.COM PC-DOS)
  51.  
  52. Procedure AccessReadOnly;
  53.  
  54. begin
  55.   if not(OpenModeByte in [0, 2]) then 
  56.     Error
  57.   else
  58.     OpenModeByte := 0;
  59. end;
  60.  
  61. procedure AccessReadWrite;
  62.  
  63. begin
  64.   if not(OpenModeByte in [0, 2]) then 
  65.     Error
  66.   else
  67.     OpenModeByte := 2;
  68. end;
  69.  
  70. The  open  mode byte for overlay,  chain,  and execute  files  is 
  71. normally 0,  Compatibility Mode with Read Access.   The addresses 
  72. for  these  mode  bytes can be found by  searching  the  run-time 
  73. library  for the bytes 00 3D.   The first occurrence is  the  one 
  74. used  for  overlay files,  and the second is used for  Chain  and 
  75. Execute files.