Guardian Programmer's Guide

Table Of Contents
Writing a Requester Program
Guardian Programmer’s Guide 421922-014
21 - 17
Coding the Requester Program
If the server process successfully processes the order, then the reply record contains
the new stock level on hand and an order record number for the newly created order.
This number is 28 digits long and is made up of a timestamp and the part number. The
PROCESS^ORDER procedure displays the order number on the terminal.
If the reply structure returns a negative quantity on hand, then the PROCESS^ORDER
procedure informs the user that the order cannot be satisfied.
If the server process cannot process the order for any reason other than inadequate
inventory, then an error condition is returned.
The READ^ORDER Procedure
The READ^ORDER procedure interacts with the order-query server ($SER3) to read
an order record given an order number. It is called from the REQUESTER procedure
when the user types “q” in response to the main-menu prompt.
On input, the terminal-interface phase of this procedure prompts the user for an order
number. The procedure expects a 28-digit number in reply.
The field-validation phase checks that the order number is 28 digits long and consists
entirely of numeric characters. If either of these conditions is not met, then the
procedure prompts the user to enter another order number.
The input is already in the form that the server expects (a 28-digit number string),
therefore no data-mapping phase is required on input.
The application-control phase sends the 28-digit number string to the $SER3 process
and waits for the response.
For an existing order number, the server returns a data structure containing the order
record and the READ^ORDER procedure displays the information on the terminal. As
with the READ^PART procedure, date information is converted for output.
If the order number does not exist, the server returns an error and the READ^ORDER
procedure prompts the user for another order number.
The EXIT^PROGRAM Procedure
The EXIT^PROGRAM procedure simply calls the FILE_CLOSE_ procedure for each
server (allowing each server to delete an entry from its opener table) and then calls the
PROCESS_STOP_ procedure to stop the requester.
The ERROR^HANDLER Procedure
The ERROR^HANDLER procedure gets called from several procedures in the
requester to handle file-system errors. This procedure interfaces with the ERROR
program to print a brief description of the file-system error. The interface with the
ERROR process is described in detail in Section 20, Interfacing With the ERROR
Program.