Guardian Programmer's Guide

Table Of Contents
Writing a Server Program
Guardian Programmer’s Guide 421922-014
22 - 36
The Process-Order Server ($SER2)
!------------------------------------------------------------
! Procedure to process an order request. This procedure
! checks that the process that sent the message is in the
! opener table before updating the part record with the new
! quantity on hand and creating an order record and writing
! it to the orders file.
!------------------------------------------------------------
PROC PROCESS^USER^REQUEST;
BEGIN
INT J^DATE^AND^TIME[0:7]; !for Gregorian date and time
INT(32) JD^NUMBER; !Julian day number
FIXED J^TIME; !Julian timestamp
INT BASE, WIDTH; !for NUMOUT procedure
INT POSITIONING^MODE; !used by KEYPOSITION
INT COUNT^READ;
INT COUNT;
INT I, J, K, L; !counters
! Check that the process handle of the requester is in the
! opener table:
I := 1;
WHILE I <= MAX^OPENERS DO
BEGIN
J := 0;
COUNT := 0;
WHILE J <= (ZSYS^VAL^PHANDLE^WLEN - 1) DO
BEGIN
IF RECEIVE^INFO[J + 6] =
OPENER^TABLE.OCB[I].PROCESS^HANDLE[J]
THEN COUNT := COUNT + 1;
J := J + 1;
END;
! If there is a match, set I to a value that will exit
! the loop:
IF COUNT = ZSYS^VAL^PHANDLE^WLEN
AND RECEIVE^INFO[3] = OPENER^TABLE.OCB[I].FILE^NUMBER THEN
I := MAX^OPENERS;
! Check if last entry has just failed to match:
IF ( COUNT <> ZSYS^VAL^PHANDLE^WLEN
OR RECEIVE^INFO[3] <> OPENER^TABLE.OCB[I].FILE^NUMBER )
AND I = MAX^OPENERS THEN