Processing Warning Messages

The _saywarn.utl utility displays all messages that have been previously stacked. It may also be used to display immediate messages.

Typically, there are no parameters passed to _saywarn.utl. The program takes its input from the global string (#Warn) and displays messages in the order they occur.

LET BBEXT$=STBL("BBEXT")
CALL BBEXT$+"_saywarn.utl"

This displays all buffered warning messages in a window and waits for a keystroke. After being displayed, the message is moved from the global string (#Warn) to the global string (#Last Warn).

By default, all warning messages are displayed as red on black. This can be modified by setting the global string (WARN_COLOR) in the configuration file.

To clear the warning buffer without displaying any messages, pass the value 1 in the FLUSH parameter to _saywarn.utl.

CALL BBEXT$+"_saywarn.utl",1

This flushes the warning buffer without displaying it to the screen.

To keep an error log of all messages, specify the name of a string file, _saywarn.utl, to append the error messages to the end of the file.

CALL BBEXT$+"_saywarn.utl",0,"errlog"

This appends the warning log buffer to the string file errlog. The file is created if it does not exist.

Warnings may be processed immediately by passing the message string directly to _saywarn.utl.

LET MESSAGE$="Unexpected error: "+STR(ERR)+"\at line
"+STR(TCB(5))+" in module "+PGM(-2)
CALL BBEXT$+"_saywarn.utl",0,$$,MESSAGE$

This displays the following message:

Unexpected error: 0
at line 2120 in module GLMAIN

Notice the use of the NEW_LINE character "\" within the message string. This prints the second string on a separate line.

Most Recent Error Message

Using the _lwarn.utl utility, the developer can get and display the last, or most recent, error message. The following repeats the most recent error displayed through _saywarn.utl.

CALL BBEXT$+"_lwarn.utl"

If _saywarn.utl has not been called, this looks for any warning messages currently buffered for _saywarn.utl and displays them. If nothing is currently buffered, it displays "There is no prior error message."