Guardian Programmer's Guide

Table Of Contents
Using the Sequential Input/Output Procedures
Guardian Programmer’s Guide 421922-014
15 - 23
Opening and Creating SIO Files
15 Using the Sequential Input/Output Procedures
Opening and Creating SIO Files
This subsection shows how to use the OPEN^FILE procedure to open SIO files. In
addition to making files available to the SIO procedures that perform I/O, the
OPEN^FILE procedure also sets up many file characteristics. This subsection shows
how to perform the following functions:
Open an SIO file
Create the SIO file at the same time as opening it
Enable block buffering and size the block buffer
Purge the data of an SIO file on opening—you need write access to do this
In addition to the functions listed above, you can set many other file-transfer
characteristics while opening an SIO file. Later parts of this section show how to
perform many of these other operations, for example:
Specify blank-padded records: see Reading and Writing SIO Files.
Open a file for nowait I/O: see Handling Interprocess Messages.
Specify the error file: see Handling SIO Errors.
Setting Flag Values in the OPEN^FILE Call
You set many of the file-transfer characteristics at file-open time using flag values
passed to the OPEN^FILE procedure. Two optional parameters, flags and
flags-mask, allow you to set or clear flag values. Each bit in the flags parameter
represents a flag value; each corresponding bit in flags-mask specifies whether the
supplied flag value should be assigned to the file. The GPLDEFS file provides literals
to make flag-setting easy.
To set a flag, set the corresponding bit in both flags and flags-mask. For example:
FLAGS := AUTO^TOF;
FLAGS^MASK := AUTO^TOF;
CALL OPEN^FILE(COMMON^FCB,
OUTFILE,
!block^buffer!,
!block^bufferlen!,
FLAGS,
FLAGS^MASK);
Note. You must apply file characteristics to each file using the SET^FILE procedure before
each file open. If you close an SIO file and then reopen it without reapplying the file
characteristics, then the SIO routines set the default values for the characteristics.