Lexical Elements of the DEC Text Processing Utility Language
4.9 Reserved Words
• RETURN—This language statement stops the execution of the procedure in
which the error occurred but continues execution of the rest of the program.
If you do not specify ABORT or RETURN, the default is to continue executing the
program from the point at which the error occurred.
DECTPU provides two forms of error handler: procedural and case style.
4.9.4.15 Procedural Error Handlers
If a WARNING status is trapped by an ON_ERROR statement, the warning
message is suppressed. However, if an ERROR status is trapped, the message is
displayed. With the ON_ERROR trap, you can do additional error handling after
the DECTPU message is displayed.
Syntax
ON_ERROR statement_1; statement_2; . . . statement_n; ENDON_ERROR;
Example 4–10 shows error statements at the beginning of a procedure. These
statements return control to the caller if the input on the command line of an
interface is not correct. Any warning or error status returned by a statement in
the body of the procedure causes the error statements to be executed.
Example 4–10 Procedure That Uses the ON_ERROR Statement
!
! Gold 7 emulation (command line processing)
!
PROCEDURE command_line
LOCAL
line_read, X;
ON_ERROR
MESSAGE ("Unrecognized command: " + line_read);
RETURN;
ENDON_ERROR;
!
! Get the command(s) to execute
!
line_read := READ_LINE ("DECTPU Statement: "); ! get line from user
!
! compile them
!
IF line_read <> ""
THEN
X := COMPILE (line_read);
ELSE
RETURN
ENDIF;
!
! execute
!
IFX<>0
THEN
EXECUTE (X);
ENDIF;
ENDPROCEDURE;
The effects of a procedural error handler are as follows:
• If you press Ctrl/C, DECTPU places an error message in the message buffer,
exits from all currently active procedures (in their reverse calling order), and
returns to the ‘‘wait for next key’’ loop.
4–24 Lexical Elements of the DEC Text Processing Utility Language