Guardian Programmer's Guide

Table Of Contents
Communicating With Printers
Guardian Programmer’s Guide 421922-014
11 - 35
Sample Program for Using a Printer
!------------------------------------------------------------
! This procedure writes a message on the terminal and checks
! for any error. If there is an error, it attempts to write
! a message about the error and the program is stopped.
!------------------------------------------------------------
PROC WRITE^LINE(BUF,LEN);
STRING .BUF;
INT LEN;
BEGIN
CALL WRITEX(TERMNUM,BUF,LEN);
IF <> THEN CALL FILE^ERRORS(TERMNUM);
END;
!------------------------------------------------------------
! This procedure asks the user for the next function to do:
!
! "r" to read records
! "u" to update a record
! "i" to insert a record
! "p" to print records
! "x" to exit the program
!
! The selection made is returned as the result of the call.
!------------------------------------------------------------
INT PROC GET^COMMAND;
BEGIN
INT COUNT^READ;
! Prompt the user for the function to be performed:
PRINT^BLANK;
PRINT^STR("Type 'r' to Read Record, ");
PRINT^STR(" 'u' to Update a Record, ");
PRINT^STR(" 'i' to Insert a Record, ");
PRINT^STR(" 'p' to Print Records, ");
PRINT^STR(" 'x' to Exit. ");
PRINT^BLANK;
SBUFFER ':=' "Choice: " -> @S^PTR;
CALL WRITEREADX(TERMNUM,SBUFFER, @S^PTR '-' @SBUFFER,
BUFSIZE,COUNT^READ);
IF <> THEN CALL FILE^ERRORS(TERMNUM);
SBUFFER[COUNT^READ] := 0;
RETURN SBUFFER[0];
END;