Guardian Programmer's Guide

Table Of Contents
Using Nowait Input/Output
Guardian Programmer’s Guide 421922-014
4 - 20
Nowait I/O: An Example
IF WRITEREADTERM(SBUFFER,@S^PTR '-' @SBUFFER,
BUFSIZE,COUNT^READ) THEN
BEGIN
LOGGED^ON := 0;
RETURN;
END;
END
UNTIL NOT (SBUFFER[0] = "y" OR SBUFFER[0] = "Y");
END;
!------------------------------------------------------------
! Procedure for appending a record. The user selected
! function "a." The user is prompted to enter comments. The
! procedure puts the comments in a new record at the end of
! the file.
!------------------------------------------------------------
PROC APPEND^RECORD;
BEGIN
INT COUNT^READ;
PRINT^BLANK;
! Prompt user for comments and read comments into the
! buffer:
SBUFFER ':=' "Enter today's comments: "
-> @S^PTR;
IF WRITEREADTERM(SBUFFER,@S^PTR '-' @SBUFFER,
BUFSIZE,COUNT^READ) THEN
BEGIN
LOGGED^ON := 0;
RETURN;
END;
! Blank out portion of buffer past last character read:
SBUFFER[COUNT^READ] ':=' " " & SBUFFER[COUNT^READ]
FOR BUFSIZE-COUNT^READ BYTES;
! Place the next-record pointer at the end of file and
! write the new record there:
CALL POSITION (LOGNUM,-1D);
IF <> THEN CALL FILE^ERRORS(LOGNUM);
CALL WRITEX(LOGNUM,SBUFFER,BUFSIZE);
IF <> THEN CALL FILE^ERRORS(LOGNUM);
END;