Guardian Programmer's Guide

Table Of Contents
Using the Sequential Input/Output Procedures
Guardian Programmer’s Guide 421922-014
15 - 15
Setting Up File Access
You set file characteristics by putting information into the FCB. There are two ways to
do this:
The user of your program can use ASSIGN commands to set file characteristics at
run time. Your program must call INITIALIZER to accept Assign messages and
give the file a logical file name using the ASSIGN^LOGICALFILENAME option of
the SET^FILE call.
You can set the file characteristics programmatically using calls to SET^FILE. File
characteristics set this way override assignments made by reading Assign
messages if the SET^FILE call comes after the INITIALIZER call. Conversely,
Assign messages read by INITIALIZER override SET^FILE calls made before the
call to INITIALIZER.
If you perform any SET^FILE operation before opening the file and that SET^FILE
operation generates an error, then the process abends. The reason for the abend is
that you cannot turn off ABORT^XFERERR until you open the file.
Some SET^FILE operations are only accepted before the file is opened; these
operations will generate an error if performed after the file is opened. See the
Guardian Procedure Calls Reference Manual for a list of SET^FILE operations that can
be done only before opening the file.
Specifying the File Access Mode
You can specify the access mode for an SIO file as read/write, read only, or write only.
Use the ASSIGN command to set the file access mode at run time. You can specify
the access mode as read/write, read only, or write only by setting the access-spec
parameter to I-O, INPUT, or OUTPUT, respectively. The following example assigns
read-only access to the file with the logical name INPUT^FILE:
1> ASSIGN INPUT^FILE,,INPUT
Use the SET^FILE ASSIGN^OPENACCESS operation to programmatically set the
acce
ss mode. You set the access mode by setting the new-value parameter to
READWRITE^ACCESS, READ^ACCESS, or WRITE^ACCESS.
The following example sets the access mode to read only for the file associated with
th
e INFILE FCB:
CALL SET^FILE(INFILE,ASSIGN^OPENACCESS,READ^ACCESS);
Note. Setting these file characteristics is optional. The system provides default values.