Guardian Programmer's Guide

Table Of Contents
Using the Sequential Input/Output Procedures
Guardian Programmer’s Guide 421922-014
15 - 27
Reading and Writing SIO Files
pTAL example:
CALL CHECK^FILE(INFILE,
FILE^FILENAME^ADDR,
@INFNAME);
TAL example:
@INFNAME := CHECK^FILE(INFILE,
FILE^FILENAME^ADDR);
One example of file status that you might want to retrieve is whether an I/O operation is
outstanding on a file. You may need this information, for example, before calling
WAIT^FILE to check for completion of an I/O operation. The FILE^LOGIOOUT
operation returns this information:
OUTSTANDING := CHECK^FILE(INFILE, FILE^LOGIOOUT);
In the above example, CHECK^FILE returns 1 in the integer variable OUTSTANDING if
there is an outstanding write operation and returns 2 if there is an outstanding read
operation on the file. If there is no I/O outstanding, CHECK^FILE returns 0. This
example is typical of the way CHECK^FILE returns status information.
Refer to the Guardian Procedure Calls Reference Manual for details on all operations
possible with the CHECK^FILE procedure call as well as syntax differences between
the TAL and pTAL versions.
Reading and Writing SIO Files
The READ^FILE procedure allows you to read records from an SIO file; the
WRITE^FILE procedure allows you to write records to a file. In addition, you can use
options to the SET^FILE and OPEN^FILE procedures to affect the way you perform I/O
with SIO procedures. This subsection explains how to use these procedures to
perform the following operations:
Read records from an SIO file using the READ^FILE procedure.
Write records to an SIO file using the WRITE^FILE procedure.
Change the interactive read prompt using the OPEN^FILE, SET^FILE, or
READ^FILE procedure.
Handle write operations that are longer than a logical record. Use either the
WRITE^FOLD flag of the OPEN^FILE procedure or the SET^WRITE^FOLD
operation of the SET^FILE procedure.
Handle blank padding on reading and writing for records. Use either the
WRITE^PAD, WRITE^TRIM, or READ^TRIM flags of the OPEN^FILE procedure,
or the SET^WRITE^PAD, SET^WRITE^TRIM, or SET^READ^TRIM operations of
the SET^FILE procedure.
Apply forms control to a printer using the forms-control-code parameter of the
WRITE^FILE procedure.