Exiting From a Routine
Developing TACL Routines
107365 Tandem Computers Incorporated
3–17
Use the routine in Figure 3-11,
argrec
, to process one or more file names, checking
for syntax but not for file existence. File names can be separated by spaces or commas.
After processing each file name, the routine scans ahead and skips over commas. It
calls itself to process each additional file name.
Figure 3-11. Processing File Name Arguments
?SECTION argrec ROUTINE
#FRAME
#PUSH fn nextfn rslt
#SET rslt [#ARGUMENT /TEXT fn/ FILENAME /SYNTAX/ OTHERWISE]
[#IF [rslt] = 2 |THEN|
#OUTPUT *** Invalid filename ***
#RETURN
]
== Process the first argument
#OUTPUT current argument = [fn]
== Check for another file name
#SET rslt [#ARGUMENT /TEXT nextfn/ FILENAME /SYNTAX/ &
COMMA END OTHERWISE]
[#CASE [rslt]
|1|
|2 3|
== Next argument is a comma or end; ignore it
#SET nextfn
|OTHERWISE|
#OUTPUT *** Invalid argument ***
#RETURN
]
== If nextfn contains a file name or there are additional
== unprocessed arguments, call self, appending the results.
[#IF NOT [#EMPTY [nextfn] [#REST]] |THEN|
#RESULT [#ROUTINENAME] [nextfn] [#REST]
]
#UNFRAME
Exiting From a Routine
To exit from a routine, use the #RETURN built-in function. #RETURN exits
immediately and does not reset any frames unless you specify #UNFRAME or
#RESET FRAMES prior to #RETURN.
You can use #RETURN to define several exit points within a routine. For examples of
the use of #RETURN, see the next subsection, “Writing an Exception Handler.”