Guardian Programmer's Guide

Table Of Contents
Writing a Requester Program
Guardian Programmer’s Guide 421922-014
21 - 25
Coding the Requester Program
!------------------------------------------------------------
! Procedure to read a part record from the $SER1 process.
! This procedure prompts the user for a part number, which it
! checks for validity before sending it to the $SER1 server
! process. The $SER1 process returns the corresponding part
! record (if there is one) from the inventory file and then
! this procedure prints the record on the terminal.
!
! This procedure is called from the main procedure when the
! user selects "r" from the main menu. It is also called
! from the PROCESS^ORDER procedure to display stock-level
! information before processing the order.
!------------------------------------------------------------
PROC READ^PART;
BEGIN
INT COUNT^READ;
INT ERROR;
INT I;
! Repeat until a valid part number entered:
REPEAT:
! Request a part number from the terminal user:
START^LINE;
PUT^STR("Enter Part Number: ");
CALL WRITEREADX(TERM^NUM,SBUFFER,
@S^PTR '-' @SBUFFER,BUFSIZE,COUNT^READ);
IF <> THEN CALL FILE^ERRORS(TERM^NUM);
! Check that part number contains 10 characters. Request
! another part number if not:
IF COUNT^READ <> 10 THEN
BEGIN
! Print diagnostic for failed test:
PRINT^LINE;
PRINT^STR("Part Number Must Contain 10 Characters");
PRINT^STR("Please type another part number ");
PRINT^BLANK;
GOTO REPEAT;
END;