
Writing an Exception Handler
Developing TACL Routines
107365 Tandem Computers Incorporated
3–21
If the user presses the BREAK key while the processing loop is running, TACL raises
the _BREAK exception and reinvokes the routine. The #CASE function executes the
_BREAK case, displays a message, and exits. If the user enters anything other than
ADD or SUB, the #CASE in the loop raises _ERROR, and TACL reinvokes the routine;
in this situation, the #CASE function takes the _ERROR path, displays a message, and
exits. To invoke this routine, load the associated file and enter:
command_processor
Figure 3-13. Sample Release Handler
?SECTION command_processor ROUTINE
== Exception handler ==
[#CASE [#EXCEPTION]
|_CALL |
== No action required when first called
|_BREAK|
#OUTPUT BREAK key pressed.
#RESET RESULTS FRAMES
#RETURN
|_ERROR|
#OUTPUT Input error occurred.
#RESET RESULTS FRAMES
#RETURN
] == End CASE
== Beginning of body of routine ==
#FRAME
#PUSH cmd
== Filter predefined exceptions only
#FILTER _BREAK _ERROR
== Processing loop: runs until invalid command or BREAK key
[#LOOP |DO|
#SET cmd [#INPUT Enter cmd: ] == Get value from terminal
[#CASE [cmd]
|ADD|
#OUTPUT ADD
|SUB|
#OUTPUT SUB
|OTHERWISE|
#OUTPUT Invalid command
#RAISE _ERROR
] == End CASE
|UNTIL| 0 = 1 == (do forever)
] == End LOOP
#UNFRAME