Guardian Programmer's Guide

Table Of Contents
Interfacing With the ERROR Program
Guardian Programmer’s Guide 421922-014
20 - 5
Reading and Processing Error-Message Text
Reading and Processing Error-Message Text
To read the error-message text, you issue a WRITEREAD[X] procedure call against the
ERROR process. Because most messages need more than one line of information,
you need to issue the WRITEREAD[X] procedure several times to read the entire
message text. The ERROR process returns an end-of-file indication when you reach
the end of the message, causing WRITEREAD[X] to return a greater than (>) condition
code.
The arrival of a user message on $RECEIVE is enough to tell the ERROR process to
reply with the next line of the message. Therefore, you need to send only a zero
length string with each WRITEREAD[X] call.
Once you have read the message text, you can process it in any way you like.
Typically, you will print the message text on the terminal or possibly save it in a log file.
The following code fragment reads a message from the ERROR process and prints it
on the home terminal:
!Loop while ERROR process still sending text:
EOF := 0;
WHILE NOT EOF DO
BEGIN
!Read the error message text into the buffer:
CALL WRITEREADX(PROCESS^FILENUMBER,SBUFFER,0,132,
BYTES^READ);
!Set flag if end of message text:
IF > THEN EOF := 1;
!Print buffer if not end of message text:
ELSE
BEGIN
CALL WRITEX(TERM^NUM,SBUFFER,BYTES^READ);
IF <> THEN ...;
END;
END;
Refer to Section 16, Creating and Managing Processes, for more details on sending
and receiving the Startup message, or to Section 8, Communicating With a TACL
Process, for a detailed discussion of the structure of the Startup message.
Closing and Deleting an ERROR Process
Once you have read the error-message text, you can close an ERROR process file
with the FILE_CLOSE_ procedure and stop an ERROR process with the
PROCESS_STOP_ procedure. For example:
CALL FILE_CLOSE_(PROCESS^FILENUMBER);
CALL PROCESS_STOP_(PROCESS^HANDLE);