Guardian Programmer's Guide

Table Of Contents
Using the IOEdit Procedures
Guardian Programmer’s Guide 421922-014
14 - 8
Creating, Opening, and Initializing an IOEdit File
Creating, Opening, and Initializing an IOEdit
File
Creating, opening, and initializing an EDIT file can all be done with one call to the
OPENEDIT_ procedure. Table 14-3 shows when OPENEDIT_ performs each of these
functions.
To create a file, the OPENEDIT_ procedure calls the FILE_CREATE_ procedure.
To open a file, the OPENEDIT_ procedure calls the FILE_OPEN_ procedure.
To initialize data structures in the EFS for the EDIT file, the OPENEDIT_ procedure
calls the INITIALIZEEDIT procedure. If the EFS does not yet exist, INITIALIZEEDIT
creates and allocates the EFS, and then initializes IOEdit data structures within the
EFS.
If the process already has the file open using another OPENEDIT_ or OPENEDIT
procedure call, then IOEdit flushes the buffers, including directory information, to disk.
Hence the file is always current when you open it. If, however, other processes have
the file open, then the file state could be inconsistent.
Opening an Already Existing File
If the EDIT file already exists, for example through use of the TEDIT program, then the
OPENEDIT_ procedure:
1. Opens the file by calling the FILE_OPEN_ procedure
2. Initializes IOEdit structures on behalf of the file in the EFS by calling the
INITIALIZEEDIT procedure
When opening a file with the OPENEDIT_ procedure, you must supply the name of the
file you want to open and a negative file number. The negative file number indicates to
IOEdit that the file is not yet open. When OPENEDIT_ finishes, the file number of the
open file is returned in the file-number parameter.
Other parameters for setting the access mode, exclusion mode, nowait mode, and
sync depth are all optional. Note that the default values and effects of some of these
parameters differ from the corresponding parameters in the FILE_OPEN_ call.
Table 14-3. Functions of the OPENEDIT_ Procedure
If the EDIT file... Then the OPENEDIT_ procedure call...
Does not yet exist Creates the file
Opens the file
Initializes data structures in the EFS for the file
Already exists but is not yet open Opens the file
Initializes data structures in the EFS for the file
Is already open by a call to FILE_OPEN_ Initializes data structures in the EFS for the file