Writing an Exception Handler
Developing TACL Routines
3–20
107365 Tandem Computers Incorporated
Figure 3-12. Sample Release Handler Template
?SECTION name ROUTINE
== Exception handler ==
[#CASE [#EXCEPTION]
|_CALL |
== No action required when first called
|_BREAK|
== Code to handle BREAK goes here
|_ERROR|
== Code to handle errors goes here
] == End CASE
== Beginning of body of routine ==
== Filter these exceptions:
#FILTER _BREAK _ERROR
== Body of executable code goes here
#UNFRAME
Keep and release handlers have slightly different structures, as shown in Table 3-3.
Table 3-3. Differences Between Keep and Release Exception Handlers
Keep Handler Contents
Release Handler Contents
The #CASE statement:
Contains a #FRAME and variable
declarations in the _CALL portion
Pushes global variables
Does not invoke #RESET
The #CASE statement:
Does not contain a #FRAME
Does not push global variables
Invokes #RESET and #RETURN
The body of code ends with #UNFRAME
The body of code starts with #FRAME and
ends with #UNFRAME
Creating a Release
Exception Handler
A release exception handler processes exceptions and returns to the calling procedure.
The _CALL path, taken when the routine is invoked by a calling program, typically
requires no action.
Use the routine in Figure 3-13,
command_processor
, as a sample release handler.
The routine requests commands from the user and allows the user to enter an ADD or
SUB command. The routine then displays the command.
The body of the routine begins with a #FRAME function call and #PUSH (or PUSH)
and #DEF entries to define variables, followed by a #FILTER function call that
declares the exceptions against which the code that follows is to be protected.