Guardian Programmer's Guide

Table Of Contents
Interfacing With the ERROR Program
Guardian Programmer’s Guide 421922-014
20 - 6
Using the ERROR Process: An Example
Using the ERROR Process: An Example
The following sample program interfaces with the ERROR process to print file-system
error messages on the home terminal. The example is made up of the following
procedures:
The PRINT^ERROR procedure is called by the FILE^USER (main) procedure
whenever a file-system error occurs. This procedure takes one formal parameter:
the file number of the file against which the error occurred. PRINT^ERROR
obtains the corresponding error number using the FILE_GETINFO_ procedure and
then passes that number to the ERROR process. Finally, it displays the returned
text on the home terminal.
FILE^USER is the main procedure. It calls the INIT procedure to initialize the
terminal and then calls the PRINT^ERROR procedure, passing it a file number.
The INIT and SAVE^STARTUP^MESSAGE procedures open the IN file as
specified in the Startup message.
?INSPECT,SYMBOLS,NOMAP,NOCODE
?NOLIST, SOURCE $TOOLS.ZTOOLD04.ZSYSTAL
?LIST
LITERAL BUFSIZE = 128;
LITERAL MAXFLEN = ZSYS^VAL^LEN^FILENAME;
LITERAL MAXPDLEN = ZSYS^VAL^LEN^PROCESSDESCR;
LITERAL ABEND = 1;
!Global variables:
INT TERMNUM; !terminal file number
INT FNUM; !generic file number
STRING .S^PTR;
STRING SBUFFER[0:BUFSIZE];
STRUCT .CI^STARTUP; !Startup message, used not only
BEGIN ! to receive Startup message
INT MSGCODE; ! from creator but also to
STRUCT DEFAULT; ! send Startup message to
BEGIN ! ERROR process and receive
INT VOLUME[0:3]; ! reply
INT SUBVOL[0:3];
END;
STRUCT INFILE;
BEGIN
INT VOLUME[0:3];
INT SUBVOL[0:3];
INT FILEID[0:3];
END;
STRUCT OUTFILE;
BEGIN
INT VOLUME[0:3];
INT SUBVOL[0:3];
INT FILEID[0:3];
END;