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.
also inhibits any deallocation of unused space. <strong>The</strong> following routine will allocate file<br />
space without any restriction on deallocation <strong>to</strong> a file opened with LRL equal <strong>to</strong> 256.<br />
Register pair DE is expected <strong>to</strong> be pointing <strong>to</strong> the file's FCB. <strong>The</strong> file's size is passed<br />
in register pair BC as the number of 256-byte records. A successful allocation will be<br />
indicated by the setting of the Z flag.<br />
WRERN LD A,B ;If space = 0, don't<br />
OR C ; do any allocation<br />
RET Z<br />
DEC BC ;Adjust for 0 offset<br />
LD A,@POSN ;Position <strong>to</strong> the "size"<br />
RST 40<br />
LD A,@WRITE ;Write a dummy sec<strong>to</strong>r<br />
RST 40<br />
JR NZ,WRERN1 ;Branch on error<br />
LD A,@REW ;Now rewind the file<br />
RST 40<br />
LD HL,0 ;Set ERN record <strong>to</strong> 0<br />
LD (FCB1+12),HL<br />
RET<br />
WRERN1 CP 27 ;Disk Full?<br />
RET NZ ;Back on some other error<br />
LD A,@REMOV ;Remove what can't fit<br />
RST 40<br />
LD A,27 ;Back with error code<br />
OR A ; and NZ flag<br />
RET<br />
Examine the functions of the file access routines listed in chapter 7. <strong>The</strong>y will relate<br />
the scope of access permitted by the operating system. More complex levels of access such<br />
as ISAM, or random access of variable length records can be supported by building<br />
appropriate routines from the provided record I/O and character I/O routines. <strong>The</strong><br />
following section will provide details on each field of the File Control Block. Most<br />
applications will not have <strong>to</strong> bother with the contents of the FCB. If you feel the need,<br />
go <strong>to</strong> it.<br />
6.4 <strong>The</strong> FILE CONTROL BLOCK (FCB)<br />
<strong>The</strong> File Control Block (FCB) is a 32-byte region that is used by the system <strong>to</strong> interface<br />
with a file that has been "opened" for access . Its contents are extremely dynamic. As<br />
records are written <strong>to</strong> or read from the disk file, specific fields in the FCB are<br />
modified. It is extremely important that during the time period that a file is open, you<br />
avoid changing the contents of the FCB unless you are sure that its alteration will in no<br />
way effect the integrity of the file.<br />
<strong>The</strong> FCB initially contains the specification of the file that is <strong>to</strong> be opened for access.<br />
Upon a successful "open", the system will replace the specification with data derived<br />
from the file's direc<strong>to</strong>ry entry. <strong>The</strong> file specification (without any password field) will<br />
be returned <strong>to</strong> the FCB when the file is closed. <strong>The</strong> information contained in each field<br />
of the FCB is as follows:<br />
6.4.1 TYPE code of the control block - <br />
This byte contains certain attributes of the control block. It correlates <strong>to</strong> the TYPE<br />
byte of the Device Control Block, especially in light of the fact that both the DCB and<br />
the FCB can be associated with a device specification (the FCB by the nature of a ROUTE<br />
<strong>to</strong> a file). <strong>The</strong> TYPE byte uses each bit as a flag per the following specifications:<br />
Bit 7 If set <strong>to</strong> a "1", it will indicate that the file is in an open condition; if<br />
set <strong>to</strong> a "0", the file is assumed closed. This bit can be tested <strong>to</strong><br />
determine the "open" or "closed" status of an FCB and is used by the<br />
6-13