Guardian Programmer's Guide

Table Of Contents
Writing a Requester Program
Guardian Programmer’s Guide 421922-014
21 - 15
Coding the Requester Program
GET^COMMAND passes the result back to the requester procedure which calls the
appropriate procedure in response to the user’s selection as follows:
To read a part record, it calls the READ^PART procedure
To process an order, it calls the PROCESS^ORDER procedure
To read an order record, it calls the READ^ORDER procedure
To stop the requester, it calls the EXIT^PROGRAM procedure
After executing the READ^PART, PROCESS^ORDER, or READ^ORDER procedure,
control returns to the REQUESTER procedure, which calls GET^COMMAND again.
The OPEN^SERVER Procedure
The CREATE^AND^OPEN^SERVER procedure works with the OPEN^SERVER
procedure to create and open server processes. It is called by the REQUESTER
procedure once for each server process. The actions of
CREATE^AND^OPEN^SERVER depend on whether the server is already running.
The first thing this procedure does is to call the PROCESS_GETPAIRINFO_ system
procedure to see whether the server process already exists.
If the server already exists, then CREATE^AND^OPEN^SERVER calls
OPEN^SERVER to try to open it. The attempt to open succeeds unless the server
rejects the attempt because its opener table is full. If the open is rejected, then the
OPEN^SERVER procedure prompts the user to try again to open the server; you can
either keep trying or choose to quit and exit the program. If the procedure succeeds in
opening the server, control returns to the REQUESTER procedure.
If the server does not exist, then CREATE^AND^OPEN^SERVER calls the
PROCESS_CREATE_ system procedure to create it. Following the normal startup
protocol, the procedure then calls OPEN^SERVER to open the server, sends it a
Startup message, closes the server, and then opens it again. If either open fails, then
the OPEN^SERVER procedure again allows the user to retry the operation.
The READ^PART Procedure
The READ^PART procedure interacts with the part-query server ($SER1) to read a
part record given a part number. It is called from the REQUESTER procedure when
the user types “r” in response to the main-menu prompt.
On input, the terminal-interface phase of this procedure prompts the user for a part
number. The procedure expects a 10-digit number in reply.
The field-validation phase checks that the part number is 10 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 part number.
The input is already in the form that the server expects it (a 10-digit number string),
therefore no data-mapping phase is required on input.