Guardian Programmer's Guide

Table Of Contents
Using the IOEdit Procedures
Guardian Programmer’s Guide 421922-014
14 - 10
Initializing an Already Open File
To create a new file, you must set the access mode to read/write. Otherwise, there is
no difference between calling OPENEDIT_ to open an existing file and calling
OPENEDIT_ to open a file that does not yet exist. The following example creates and
opens a file called MYFILE:
LITERAL READ^WRITE = 0;
.
.
FILE^NAME ':=' "$USERVOL.MYSUBVOL.MYFILE" -> @S^PTR;
NAME^LEN := @S^PTR '-' @FILE^NAME;
FILE^NUM := -1;
ACCESS^MODE := READ^WRITE;
ERROR := OPENEDIT_(FILENAME:NAME^LEN,
FILE^NUM,
ACCESS^MODE);
IF ERROR > 0 THEN ...
The OPENEDIT_ procedure returns file-system error 11 if the file is not open for
read/write access.
Initializing an Already Open File
If an EDIT file has already been opened using, for example, the FILE_OPEN_
procedure, then you can initialize the IOEdit data structures in the EFS by calling the
OPENEDIT_ procedure. The OPENEDIT_ procedure establishes that the file exists
and that it is an EDIT file and then calls the INITIALIZEEDIT procedure to perform the
initialization.
To initialize an already open file, you must supply OPENEDIT_ with the file number
returned by the FILE_OPEN_ procedure; for example:
FILE^NAME ':=' "$USERVOL.MYSUBVOL.DIARY" -> @S^PTR;
NAME^LEN := @S^PTR '-' @FILE^NAME;
ERROR := FILE_OPEN_(FILE^NAME:NAME^LEN,FILE^NUM);
IF ERROR <> 0 THEN ...
.
.
ERROR := OPENEDIT_(FILENAME:NAME^LEN,
FILE^NUM);
IF ERROR > 0 THEN ...