The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...
The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...
The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
A high level language permits you the opportunity of indicating your access level in the<br />
language syntax. For example, BASIC requires you <strong>to</strong> specify whether a sequentially<br />
accessed file is <strong>to</strong> be INPUT or OUTPUT corresponding <strong>to</strong> READ or WRITE. <strong>The</strong> operating<br />
system has no facility for identifying the maximum level of access desired for any<br />
particular opening of the file except through the passwords and access protection level.<br />
6.2.3 Opening Files<br />
Files opened with UPDATE or greater access are indicated as open in their direc<strong>to</strong>ry entry<br />
record by the setting of a "file open bit". Any subsequent open attempt will result in a<br />
force <strong>to</strong> READ access protection and return the appropriate "File already open" error<br />
code. This is designed primarily for the use of shared access multiplexed disk drives<br />
where files are shared among a number of users. This arrangement will restrict the<br />
altering (but not reading) of file data <strong>to</strong> only one user at a time. It is therefore<br />
important for applications <strong>to</strong> CLOSE files as soon as the application is finished with the<br />
file access. It is also important for applications <strong>to</strong> trap the "File already open" error<br />
and take appropriate action. Realize that files protected <strong>to</strong> READ only, may be opened by<br />
multiple users and still be opened for updating by the maintainer providing the proper<br />
OWNER password is provided. <strong>The</strong> importance of maintaining proper levels of file<br />
protection through the use of passwords and protected access levels should not be taken<br />
lightly.<br />
For the convenience of applications that access files only for reading, a facility for<br />
forcing the file access <strong>to</strong> READ only when a file is opened has been provided in the DOS.<br />
This facility will inhibit the "file open bit" and set the File Control Block access<br />
permission <strong>to</strong> READ (providing that the access permission level granted according <strong>to</strong> the<br />
password entered was READ or greater). Under this linkage, it is not necessary <strong>to</strong> close<br />
the file when you are finished accessing it as no direc<strong>to</strong>ry updating will be done. Of<br />
course if you want the system <strong>to</strong> recover the filespec and place it in<strong>to</strong> the FCB , you will<br />
have <strong>to</strong> close the file. Check the discussion covering the FORCE-<strong>to</strong>-READ flag (bit-0 of<br />
the SFLAG$) in the @FLAGS SuperVisor Call. Note that once the FORCE-<strong>to</strong>-READ flag has been<br />
set, the next @OPEN or @INIT SuperVisor Call request will au<strong>to</strong>matically reset the bit<br />
after satisfying the request.<br />
When a file is opened, the system needs <strong>to</strong> be <strong>to</strong>ld where the disk file I/O buffer is<br />
located. This buffer is used <strong>to</strong> transfer a full sec<strong>to</strong>r of data <strong>to</strong> and from the disk. <strong>The</strong><br />
system also needs <strong>to</strong> be <strong>to</strong>ld what Logical Record Length (LRL) is <strong>to</strong> be used while the<br />
file is open. If the LRL at open time differs from the LRL of the file as noted in the<br />
direc<strong>to</strong>ry, the OPEN routine will return an "LRL open fault" error code BUT THE FILE WILL<br />
STILL BE PROPERLY OPENED ACCORDING TO THE LRL PASSED IN THE OPEN REQUEST. <strong>The</strong> error code<br />
is your indication that a different LRL is being used. If the LRL is 256, then the system<br />
does not block and deblock the data records and will expect that all data <strong>to</strong> I/O will be<br />
using the disk file I/O buffer. If the LRL is in the range , then the disk file<br />
I/O buffer is used only for transferring full sec<strong>to</strong>rs <strong>to</strong> and from the disk. Say, for<br />
example, a file has 200-byte records, the second record of the file is partially<br />
contained in the first sec<strong>to</strong>r and partially contained in the second sec<strong>to</strong>r. <strong>The</strong> file is<br />
said <strong>to</strong> SPAN two sec<strong>to</strong>rs. This requires a separate buffer <strong>to</strong> hold the record data while<br />
the system uses the disk file I/O buffer for the transfer of the sec<strong>to</strong>r. <strong>The</strong> program then<br />
will specify a USER RECORD buffer (UREC) that will be used by the system <strong>to</strong> transfer the<br />
data records <strong>to</strong> and from the disk file I/O buffer on each I/O request. Thus, whenever a<br />
file record spans two sec<strong>to</strong>rs, the system will have the necessary buffering regions <strong>to</strong><br />
fully block and deblock the record. Note that the arrangement of separate disk file I/O<br />
buffers for each file provides greater flexibility for accessing multiple files<br />
coincidentally.<br />
To illustrate the linkage necessary <strong>to</strong> open an existing file, we will be referencing an<br />
80-byte record length file with the specification, BULKLOAD/DAT:2. <strong>The</strong> file has an OWNER<br />
password, blank USER password with protection level of WRITE. <strong>The</strong> filespec has been<br />
placed in<strong>to</strong> the File Control Block as shown in figure 6-2. Note that the filespec is left<br />
justified and is terminated with an ETX (X'03') character. <strong>The</strong> ETX is au<strong>to</strong>matically<br />
6-6