Enscribe Programmer's Guide

Figure 12 Example of Encountering the EOF
0 512 1024 1536 3584 4096
(EOF)Relative Byte Address
Read #1
(512
Bytes)
Read #2
(512
Bytes)
Read #3
(512
Bytes)
Read #8
(512
Bytes)
Read #9
(CCG)
Each of the first eight READ calls transfers 512 bytes into the designated buffer, returns a num^read
of 512, and sets the condition code to CCE (operation successful).
The ninth READ fails, no data is transferred into the buffer, num^read is returned as zero, and the
condition code CCG indicates that you encountered the EOF.
If the read count is changed from 512 to 400, the results of executing the same read loop are
somewhat different, as illustrated in Figure 13 (page 66)
In this case, the first 10 READ calls each transfer 400 bytes into the designated buffer, return a
num^read of 400, and set the condition code to CCE (operation successful). The eleventh READ
transfers 96 bytes into the buffer, returns a num^read of 96, and sets the condition code to CCE.
The twelfth READ fails and sets the condition code to CCG.
Figure 13 Example of Encountering the EOF (Short READ)
690400630080040
(EOF)Relative Byte Address
Read #1
(400
Bytes)
Read #2
(400
Bytes)
Read #10
(400
Bytes)
Read #11
(96
Bytes)
4000
Read #12
(CCG)
Random Access
You access Enscribe unstructured disk files by using the relative-byte-address parameter of the
POSITION system procedure to explicitly set the file pointers. To update data in an unstructured
disk file at relative byte address 81920, you could use this sequence:
CALL FILE_SETPOSITION_ ( filenum, 81920F );
CALL READUPDATE ( filenum, buffer, 512 );
CALL WRITEUPDATE ( filenum, buffer, 512 );
The call to FILE_SETPOSITION_ sets both the current-record and next-record pointers to relative
byte 81920.
The call to READUPDATE transfers 512 bytes from the disk to the designated buffer, starting at
relative byte 81920 in the disk file. Following the read operation, the file pointers are unchanged.
The WRITEUPDATE procedure replaces the just-read data with new data in the same location on
disk. The file system transfers 512 bytes from the buffer to the file at relative byte 81920. Following
the write operation, the file pointers are unchanged.
Appending to the End of a File
You can also use the FILE_SETPOSITION_ procedure to append data to the end of an unstructured
disk file. To set the next-record pointer to the EOF position, pass -1 as the relative byte address
parameter in a FILE_SETPOSITION_ call:
CALL FILE_SETPOSITION_ ( filenum, -1F );
66 Unstructured Files