Writing an Exception Handler
Developing TACL Routines
107365 Tandem Computers Incorporated
3–25
Note
The examples in this subsection include an EXIT case for testing purposes, which allows you to exit the
routines. To prohibit exits, delete the EXIT case from the #FILTER statement and from the exception
handler and main loop.
To invoke
restricted_cmd_processor
, load the file and enter:
restricted_cmd_processor
Figure 3-15. Sample Keep Exception Handler
?SECTION restricted_cmd_processor ROUTINE
[#CASE [#EXCEPTION]
|_CALL |
#FRAME
#PUSH cmd
|_BREAK|
#OUTPUT BREAK key pressed.
|_ERROR|
#OUTPUT TACL error occurred.
|EXIT| == For demo only
#RESET FRAMES RESULTS
#RETURN
|OTHERWISE|
#OUTPUT Unknown exception occurred.
] == End #CASE
== Filters predefined exceptions only
#FILTER _BREAK _ERROR EXIT
== After you enter this loop, control stays here unless the
== routine is processing an exception.
[#LOOP |DO|
#SET cmd [#INPUT Enter cmd: ] == Get value from terminal
[#CASE [cmd]
|ADD|
#OUTPUT ADD
|SUB|
#OUTPUT SUB
|EXIT|
#RAISE EXIT == For demo only
|OTHERWISE|
#OUTPUT Invalid command
#RAISE _ERROR
] == End CASE
|UNTIL| 0 == Always false
] == End LOOP
#UNFRAME