Guardian Programmer's Guide

Table Of Contents
Using Nowait Input/Output
Guardian Programmer’s Guide 421922-014
4 - 16
Nowait I/O: An Example
!------------------------------------------------------------
! Procedure to write messages on the terminal and read the
! user's reply. If there is an error, this procedure
! attempts to write a message about the error and the program
! is stopped. If the read takes longer than the defined wait
! time, the procedure returns 1 as its result to signal the
! caller of the timeout. Otherwise it returns 0.
!------------------------------------------------------------
INT PROC WRITEREADTERM(BUF,LEN,READCOUNT,COUNT^READ);
STRING .EXT BUF;
INT LEN;
INT READCOUNT;
INT .COUNT^READ;
BEGIN
INT ERR;
! Prompt the user for input:
CALL WRITEREADX(TERMNUM,BUF,LEN,READCOUNT);
IF <> THEN CALL FILE^ERRORS(TERMNUM);
CALL AWAITIOX(TERMNUM,
!buffer^address!,
COUNT^READ,
!tag!,
WAIT^TIME);
IF <> THEN
! Check for timeout:
BEGIN
CALL FILE_GETINFO_(TERMNUM,ERR);
IF ERR = 40 THEN RETURN 1;
CALL FILE^ERRORS(TERMNUM);
END;
BUF[COUNT^READ] := 0;
RETURN 0;
END;