Guardian Programmer's Guide

Table Of Contents
Using the Sequential Input/Output Procedures
Guardian Programmer’s Guide 421922-014
15 - 41
Waiting for One File
Once the file is open, you can issue an I/O operation against it, such as the
READ^FILE operation shown below. Note that the sixth parameter must contain a
positive number for a nowait operation:
CALL READ^FILE(DFILE,
READ^BUFFER,
BYTES^READ,
!prompt^count!,
!max^read^count!,
1);
Nothing is returned at this point in either the read buffer or the count of bytes read,
because the I/O operation has not yet finished.
You complete the I/O operation by calling the WAIT^FILE procedure. You must supply
the FCB name, a variable to contain the read count, and a value for the time-out
parameter. The time-out parameter causes WAIT^FILE to respond in one of the
following ways:
Wait indefinitely for the I/O to finish by omitting the time-out parameter or setting
it to -1D:
CALL WAIT^FILE(DFILE,
BYTES^READ);
On return, BYTES^READ contains the number of bytes transferred by the I/O
operation. The buffer specified in the I/O call contains the transferred bytes.
Return immediately whether the I/O finished or not by setting the time-out
parameter to zero. This option makes sense only if the WAIT^FILE call is in a loop
that gets executed repeatedly until the I/O finishes:
LITERAL RETURN^IMMEDIATELY = 0;
.
.
CALL WAIT^FILE(DFILE,
BYTES^READ,
RETURN^IMMEDIATELY);
You can use the FILE^LOGIOOUT operation of the CHECK^FILE procedure to
check for completion. If the return value is nonzero, then the I/O is still
outstanding. If the return value is zero, then the I/O has finished.
OUTSTANDING := CHECK^FILE(DFILE,
FILE^LOGIOOUT);
Wait until either the I/O finishes or the time-out value expires. You specify the time
in one-hundredths of a second. The following example times out after 30 seconds:
TIME^LIMIT := 3000D;
CALL WAIT^FILE(DFILE,BYTES^READ,TIME^LIMIT);
Again you can use the FILE^LOGIOOUT operation of the CHECK^FILE procedure
to find out whether the I/O finished.