Guardian Programmer's Guide

Table Of Contents
Writing a Server Program
Guardian Programmer’s Guide 421922-014
22 - 8
Writing a Server Program: An Example
!Check for lost openers:
INDEX := -1;
DO
BEGIN
STATUS := OPENER_LOST_(BUFFER:COUNT^READ,
OPENER^TABLE[1],
INDEX,
MAX^OPENERS,
$LEN(OPENER^TABLE[1]));
IF STATUS = 6 THEN
NUMBER^OF^OPENERS := NUMBER^OF^OPENERS - 1;
END
UNTIL STATUS = 0 OR STATUS = 2
OR STATUS = 3 OR STATUS = 7;
.
.
!Process other system messages.
.
.
END;
Writing a Server Program: An Example
The sample server programs given in this section provide service to the requester
program described in Section 21, Writing a Requester Program. The servers and the
requester together provide the following application functions:
Queries the database to find out how much of a given item is on hand.
Processes an order by updating the inventory database and creating an order
record.
Queries the status of an existing order to find out who placed the order, when the
order was placed, and whether the order has been shipped.
A separate server process provides database ser
vice for each of the above functions.
Application Overview
The application database is made up of part records and order records. The part
records are contained in the inventory file and the order records in the orders file.
The Inventory File
The inventory file contains one record for each item that the store carries. A part
record contains the following information about a given part:
The part number
A brief description of the item
The quantity of the item currently on hand