Guardian Programmer's Guide

Table Of Contents
Writing a Requester Program
Guardian Programmer’s Guide 421922-014
21 - 24
Coding the Requester Program
!-----------------------------------------------------------
! Procedure to write a message on the terminal and check
! for any error. If there is an error, this procedure
! attempts to write a message about the error and then
! stops the program.
!-----------------------------------------------------------
PROC WRITE^LINE(BUF,LEN);
STRING .BUF;
INT LEN;
BEGIN
CALL WRITEX(TERM^NUM,BUF,LEN);
IF <> THEN CALL FILE^ERRORS(TERM^NUM);
END;
!------------------------------------------------------------
! Procedure to prompt the user for the next function to be
! performed:
!
! "r" to read a part record
! "p" to process an order
! "q" to query an order
! "x" to exit the program
!
! The selection made is returned as a 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 a part record, ");
PRINT^STR(" 'p' to process an order, ");
PRINT^STR(" 'q' to query an order, ");
PRINT^STR(" 'x' to exit. ");
SBUFFER ':=' "Choice: " -> @S^PTR;
CALL WRITEREADX(TERM^NUM,SBUFFER,@S^PTR '-' @SBUFFER,
BUFSIZE,COUNT^READ);
IF <> THEN CALL FILE^ERRORS(TERM^NUM);
SBUFFER[COUNT^READ] := 0;
RETURN SBUFFER[0];
END;