Guardian Programmer's Guide

Table Of Contents
Writing a Requester Program
Guardian Programmer’s Guide 421922-014
21 - 16
Coding the Requester Program
The application-control phase sends the 10-digit number string to the $SER1 server
process and waits for the response.
For an existing part number, the server returns a data structure containing the part
record and the READ^PART procedure displays the information on the terminal. Date
information contained in the returned data structure is in the form of a 48-bit numeric
timestamp. The READ^PART procedure converts this information first into a 16-bit
integer representing the Gregorian date and time and then converts the numbers into
ASCII characters for output.
If the part number does not exist, the server returns an error and the READ^PART
procedure prompts the user for another part number.
The PROCESS^ORDER Procedure
The PROCESS^ORDER procedure communicates with the process-order server
($SER2) to process a customer order. It is called from the REQUESTER procedure
when the user types “p” in response to the main-menu prompt.
This procedure prompts the terminal operator to enter the part number of the item to be
ordered, the quantity, and the customer’s name, address, and credit-card number.
This procedure first calls the READ^PART procedure to prompt for the part number
and provide the operator with inventory information to see whether the store can satisfy
the order.
The field-validation phase enforces the following:
The quantity requested must be numeric.
The customers first name and last name must be alphabetic and have from 1
through 20 characters. The middle initial should be a single character or omitted.
The customers street address must contain up to 48 alphabetic and numeric
characters.
The city name can be up to 24 characters long, all of which must be alphabetic.
The zip code (for the purpose of this example) must consist of seven characters:
the first two characters must be alphabetic, and the remaining five must be
numeric.
The customers credit-card number must be 16 numeric characters.
The PROCESS^ORDER procedure prompts the user to reenter any part of the above
information that does not meet the stated requirements.
The data-mapping phase involves converting the ASCII input for the quantity into a
numeric value and then packing all input into a data structure to send to the server.
Application control involves selecting the server to send the data structure to. In this
case, the server is the $SER2 process. The PROCESS^ORDER procedure then waits
for the reply.