Guardian Programmer's Guide

Table Of Contents
Communicating With Processes
Guardian Programmer’s Guide 421922-014
6 - 33
Programming the Requester
The MAIN procedure responds to the user’s selection by calling the appropriate
procedure:
The READ^RECORD procedure allows the user to read one record followed
optionally by subsequent sequential reads. It prompts the user for a part number
and then sends the part number, along with a function code for an approximate
read, to the server process. The response from the server contains the first record
with a key equal to or greater than the supplied part number or an indication that
the file contains no such record.
If the reply contains a record, then the READ^RECORD procedure calls the
DISPLAY^RECORD procedure to display the record on the users terminal. If the
reply contained an end-of-file indication, then the READ^RECORD procedure
prints a “no such record” message on the users terminal.
If the user chooses to read more records, then the procedure sends another read
request to the server process using the key value returned by the last read
operation. This time the function code is set for a read-next operation instead of
an approximate read.
The UPDATE^RECORD procedure displays the record for update before
prompting the user for the updated information. First it prompts the user for the
key to the record to be updated (the part number). It then sends the part number
to the server process along with a read-exact function code. The response from
the server is either the record that the user wants to update or an indication that
the record does not exist.
If the record does not exist, the procedure prints a diagnostic and returns control to
the main procedure. If a record is returned, the procedure calls
DISPLAY^RECORD to display the record on the user’s terminal then calls
ENTER^RECORD to prompt the user to enter new values. Once the values are
entered, UPDATE^RECORD sends the updated record to the server along with a
write function code. The response from the server indicates that the write was
successful, and control returns to the MAIN procedure.
The INSERT^RECORD procedure calls the ENTER^RECORD procedure to
prompt the user to enter a new record. The INSERT^RECORD procedure then
sends this data structure to the server process along with a function code
indicating that the server should write a new record. The response from the server
is either a confirmation that the write was completed as intended or an indication
that the write could not proceed because a record with the same key already
exists. In either case, control is returned to the MAIN procedure. If the write could
not be completed, INSERT^RECORD prints a message on the users terminal.
The EXIT^PROGRAM procedure stops the requester program. The server
continues to run because other requesters may still be using it.
The TAL code for the requester program follows.