Guardian Programmer's Guide

Table Of Contents
Using the Sequential Input/Output Procedures
Guardian Programmer’s Guide 421922-014
15 - 25
Block Buffering With SIO Files
If the file already exists, then the above open will proceed, ignoring the request to
create the file. You can, however, cause the open to fail if the file already exists by
setting the MUSTBENEW flag. If the MUSTBENEW flag is set when you attempt to
create a file, and if the file already exists, the OPEN^FILE call returns error 10:
CALL SET^FILE(OUTFILE,
ASSIGN^OPENACCESS,
WRITE^ACCESS);
.
.
FLAGS := AUTO^CREATE + MUSTBENEW;
FLAGS^MASK := AUTO^CREATE + MUSTBENEW;
ERROR := OPEN^FILE(COMMON^FCB,
OUTFILE,
!block^buffer!,
!block^bufferlen!,
FLAGS,
FLAGS^MASK);
Note that the MUSTBENEW flag is effective only if the AUTO^CREATE flag is also set
and the file FCB is set up for write-only access. If either of these conditions is not true,
then the open proceeds.
By default, the AUTO^CREATE flag is set but the MUSTBENEW flag is not set.
To create a file with an access mode other than write only, you must create the file with
write-only access as described above, close the file, change the access permissions
with SET^FILE, and then reopen the file.
Block Buffering With SIO Files
You can specify a block buffer when you open an SIO file.
The use of the block buffer depends on the type of file you are opening:
For structured Enscribe files, you use sequential block buffering to improve the
efficiency of read operations. You simply set the buffer size. See the Enscribe
Programmers Guide for details.
For EDIT files, the block buffer must provide space for the EDIT file pages as they
are assembled or disassembled. See Accessing EDIT Files later in this section.
For SIO files that are neither Enscribe files nor EDIT files, the buffer is used for
record blocking and unblocking. For record blocking and unblocking to happen,
your program must perform the following operations:
²
Supply the block buffer name and length to the OPEN^FILE procedure call
²
Size the block buffer to contain at least one logical record
²
Set the access mode in the FCB to read only or write only
Caution. Do not mix regular Guardian procedure calls with SIO procedure calls on a file for
which you are providing a block buffer. You might corrupt your data.