Guardian Programmer's Guide

Table Of Contents
Communicating With Printers
Guardian Programmer’s Guide 421922-014
11 - 43
Sample Program for Using a Printer
! Loop reading and displaying records until user declines
! to read the next record (any response other than "y"):
DO BEGIN
PRINT^BLANK;
! Read a record from the part file.
! If end-of-file is reached,
! return control to the main procedure.
CALL READX(PARTFILE^NUM,PART^RECORD,$LEN(PART^RECORD));
IF <> THEN
BEGIN
CALL FILE_GETINFO_(PARTFILE^NUM,ERROR);
IF ERROR = 1 THEN
BEGIN
PRINT^STR("No such record");
RETURN;
END;
CALL FILE^ERRORS(PARTFILE^NUM);
END;
! Display the record on the terminal:
CALL DISPLAY^RECORD;
PRINT^BLANK;
! Prompt the user to read the next record (user must
! respond "y" to accept, otherwise return to select
! next function):
SBUFFER ':=' ["Do you want to read another ",
"record (y/n)? "]
-> @S^PTR;
CALL WRITEREADX(TERMNUM,SBUFFER,@S^PTR '-' @SBUFFER,
BUFSIZE,COUNT^READ);
IF <> THEN CALL FILE^ERRORS(TERMNUM);
SBUFFER[COUNT^READ] := 0;
END
UNTIL NOT (SBUFFER[0] = "y" OR SBUFFER[0] = "Y");
END;