Guardian Programmer's Guide

Table Of Contents
Communicating With Processes
Guardian Programmer’s Guide 421922-014
6 - 11
Reading Messages for Two-Way Communication
Reading Messages for Two-Way Communication
Use the READUPDATE[X] procedure to read a message from $RECEIVE if you want
to reply to the message with data. READUPDATE[X] reads the message without
terminating the WRITEREAD[X] procedure issued by the sender of the message. The
WRITEREAD[X] procedure instead waits for a reply.
An example of a READUPDATEX call follows:
CALL READUPDATEX(RECV^NUM,
SBUFFER,
RCOUNT);
IF <> THEN ...
Replying to Messages
After reading a message from $RECEIVE using the READUPDATEX procedure, use
the REPLYX procedure to send the reply. This procedure sends data back to the
sender of the original message and returns an error indication:
STRUCT .RECORD;
BEGIN
INT FUNCTION^CODE;
INT ACCOUNT^NUMBER;
INT AMOUNT;
END;
RECORD.AMOUNT := 1250;
WCOUNT := $LEN(RECORD);
ERROR := 0;
CALL REPLYX(RECORD,
WCOUNT,
!count^written!,
!message^tag!,
ERROR);
IF <> THEN ...
Returning Data
In the example above, the first parameter in the REPLYX call contains the reply
message; in this case, a data record requested by the sender.
Returning Error Information
The ERROR parameter in the above example can also be returned to the message
originator. Its purpose is to return an indication that there is a problem. Typically, the
reply data does not contain the expected result. The requested operation may not
have been completely and correctly performed.
The range of error codes between 256 and 511 is reserved for application programs to
use. You can freely define the meanings of these error codes yourself, as part of the
relationship between the requester and the server.