Guardian Programmer's Guide

Table Of Contents
Using the Sequential Input/Output Procedures
Guardian Programmer’s Guide 421922-014
15 - 38
Opening an EDIT File
Opening an EDIT File
The way you open an EDIT file depends on whether you will read from the file or write
to the file. Specifically, the minimum size of the block buffer is different for reading and
for writing. The block buffer provides space for the EDIT file pages as they are
assembled or disassembled.
Writing to an EDIT File
To write to a file in EDIT format, you must open the file with a block buffer of at least
1024 bytes:
CALL SET^FILE(EDITFILE,
ASSIGN^OPENACCESS,
WRITE^ACCESS);
EDBLKLEN := 1024;
CALL OPEN^FILE(COMMON^FCB,
EDITFILE,EDBLKBUF,EDBLKLEN);
Attempting to open an EDIT file for writing with a block buffer less than 1024 bytes long
causes SIO error 518, SIOERR^BUFTOOSMALL.
Reading From an EDIT File
To read from a file in EDIT format, you must open the file with a block buffer of at least
144 bytes:
CALL SET^FILE(EDFILE,
ASSIGN^OPENACCESS,
READ^ACCESS);
EDBLKLEN := 256;
CALL OPEN^FILE(COMMON^FCB,
EDFILE,EDBLKBUF,EDBLKLEN);
Attempting to open an EDIT file for reading with a block buffer less than 144 bytes long
also causes an SIOERR^BUFTOOSMALL error (error 518).
Setting the Read Position
Use the SET^EDITREAD^REPOSITION operation of the SET^FILE procedure to read
from a specific position in an EDIT file.
Normally, you read from an EDIT file sequentially, just as from any other file. However,
a feature specific to EDIT files allows you to save the current position and then return
to it later.
The reposition mechanism works like this. While working on the file, you reach a
position that you may want to return to later.
1. Save the current position. You do this by saving the second through fourth words
of the block buffer you specified to the OPEN^FILE procedure. These words