home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TXTSHARE.ZIP / TXTSHARE.DOC next >
Encoding:
Text File  |  1988-01-10  |  2.9 KB  |  62 lines

  1.  
  2.  
  3.     With the advent of version 4.0 of the Turbo Pascal compiler, it is now
  4. possible to create programs that access shared files (in a network
  5. environment) without generating Abort, Retry, Ignore messages.  This is
  6. accomplished through the use of a new standard global variable called
  7. FileMode.
  8.  
  9.     When Turbo is told to open a file, DOS function 3Dh is called to do the
  10. actual work.  Before this system call is made, the AL register is populated
  11. with the contents of the FileMode variable.  The value of the AL register
  12. tells DOS what access rights will be given to the program opening the file.
  13. In older versions of the compiler, AL was always 0, 1, or 2.  Now, however,
  14. the programmer can determine the access rights required, load the FileMode
  15. variable with the appropriate access code, and have the file opened
  16. without fear of causing problems in a shared environment.
  17.  
  18.     Unfortunately, the use of FileMode does not extend to files of type
  19. TEXT.  TEXT files are always opened with a filemode of 0 (read only), 1
  20. (write only), or 2 (read/write).  This has the unfortunate consequence of
  21. restricting programs used in a network environment to manipulation of typed
  22. and untyped files only.
  23.  
  24.     Also new in Turbo Pascal v4.0 is the ability to create custom text file
  25. device drivers that completely replace Turbo's own file handling routines.
  26. The file TXTSHARE.PAS implements such a driver.  This file compiles to a
  27. UNIT (yet another new feature in the language) that, when used, extends the
  28. use of the FileMode variable to TEXT files.
  29.  
  30.     Here's how it works:
  31.  
  32.       1).  The ASSIGNTEXT procedure replaces Turbo's ASSIGN procedure.
  33.            This procedure is used to associate a TEXT file variable with a
  34.            DOS filename and sets up an internal data structure. This
  35.            procedure MUST be called before the text file is opened. The
  36.            syntax of the procedure is:
  37.  
  38.                    ASSIGNTEXT(Var f : Text; filespec : String)
  39.  
  40.       2).  Determine the access rights required for the file and load the
  41.            FileMode variable with the appropriate DOS access code (see the
  42.            section on DOS function 3Dh in the DOS Technical Reference for a
  43.            complete discussion on access codes).
  44.  
  45.       3).  Open the file (as usual) with the RESET, REWRITE, or APPEND
  46.            procedures
  47.  
  48.       4).  Do your stuff ...
  49.  
  50.       5).  Close the file (as usual) with the CLOSE procedure.
  51.  
  52.  
  53.     There is one other global variable provided in this unit called
  54. WriteTextEofChar.  This is a boolean variable and when set TRUE, tells the
  55. driver to append an eof character (ascii 26) to the end of any file opened
  56. with REWRITE or APPEND before closing that file.  The default value of this
  57. variable is FALSE (ie. no eof character is written before closing).
  58.  
  59.  
  60.                                                             rpb
  61.                                                           1/10/88
  62.