home *** CD-ROM | disk | FTP | other *** search
-
-
- With the advent of version 4.0 of the Turbo Pascal compiler, it is now
- possible to create programs that access shared files (in a network
- environment) without generating Abort, Retry, Ignore messages. This is
- accomplished through the use of a new standard global variable called
- FileMode.
-
- When Turbo is told to open a file, DOS function 3Dh is called to do the
- actual work. Before this system call is made, the AL register is populated
- with the contents of the FileMode variable. The value of the AL register
- tells DOS what access rights will be given to the program opening the file.
- In older versions of the compiler, AL was always 0, 1, or 2. Now, however,
- the programmer can determine the access rights required, load the FileMode
- variable with the appropriate access code, and have the file opened
- without fear of causing problems in a shared environment.
-
- Unfortunately, the use of FileMode does not extend to files of type
- TEXT. TEXT files are always opened with a filemode of 0 (read only), 1
- (write only), or 2 (read/write). This has the unfortunate consequence of
- restricting programs used in a network environment to manipulation of typed
- and untyped files only.
-
- Also new in Turbo Pascal v4.0 is the ability to create custom text file
- device drivers that completely replace Turbo's own file handling routines.
- The file TXTSHARE.PAS implements such a driver. This file compiles to a
- UNIT (yet another new feature in the language) that, when used, extends the
- use of the FileMode variable to TEXT files.
-
- Here's how it works:
-
- 1). The ASSIGNTEXT procedure replaces Turbo's ASSIGN procedure.
- This procedure is used to associate a TEXT file variable with a
- DOS filename and sets up an internal data structure. This
- procedure MUST be called before the text file is opened. The
- syntax of the procedure is:
-
- ASSIGNTEXT(Var f : Text; filespec : String)
-
- 2). Determine the access rights required for the file and load the
- FileMode variable with the appropriate DOS access code (see the
- section on DOS function 3Dh in the DOS Technical Reference for a
- complete discussion on access codes).
-
- 3). Open the file (as usual) with the RESET, REWRITE, or APPEND
- procedures
-
- 4). Do your stuff ...
-
- 5). Close the file (as usual) with the CLOSE procedure.
-
-
- There is one other global variable provided in this unit called
- WriteTextEofChar. This is a boolean variable and when set TRUE, tells the
- driver to append an eof character (ascii 26) to the end of any file opened
- with REWRITE or APPEND before closing that file. The default value of this
- variable is FALSE (ie. no eof character is written before closing).
-
-
- rpb
- 1/10/88