Guardian Programmer's Guide

Table Of Contents
Using the Sequential Input/Output Procedures
Guardian Programmer’s Guide 421922-014
15 - 43
Waiting for Any File
Guardian procedures on the same file. You therefore need to obtain the file
numbers to be able to access the files using the AWAITIO call.
3. Issue a nowait I/O operation against each file. Here, READ^FILE calls are issued.
4. Issue the AWAITIO call to receive the first I/O operation that finishes. You need to
set the file number to -1, indicating that a response from any file will do. On return
from the AWAITIO call, the file-number parameter indicates which I/O finished;
the count-returned parameter contains the number of bytes read, and the data
itself is in the buffer indicated in the originating READ^FILE call.
5. Check the file number returned by the AWAITIO call to see which I/O finished, and
execute the code appropriate for that file.
6. For the file established in the previous step, you must update the file-state
information in the FCB. You have to do this manually, because AWAITIO is not an
SIO procedure and therefore does none of this for you. You must update:
a. The I/O done flag
b. The number of bytes transferred
c. The error code
A combination of SET^FILE and WAIT^FILE procedure calls enables you to do
this.
The following TAL example provides skeletal code for waiting for I/O from more than
one SIO file:
!Open all terminals for nowait I/O:
CALL OPEN^FILE(COMMON^FCB,TERM1,
!block^buffer!,
!block^bufferlen!,
NOWAIT,NOWAIT,
!max^record^len!,
!prompt^char!,
OUTFILE);
CALL OPEN^FILE(COMMON^FCB,TERM2,
!block^buffer!,
!block^bufferlen!,
NOWAIT,NOWAIT,
!max^record^len!,
!prompt^char!,
OUTFILE);
!Establish the file numbers of the open terminal files. (We
!need these values later for getting information through the
!FILE_GETINFO_ procedure call):
@T1^FNUM := CHECK^FILE(TERM1,FILE^FNUM^ADDR);
@T2^FNUM := CHECK^FILE(TERM2,FILE^FNUM^ADDR);
.
.
!Start a read operation on each open terminal file:
CALL READ^FILE(TERM1,READ^BUFFER,BYTES^READ,