TACL Reference Manual
Variables
HP NonStop TACL Reference Manual—429513-018
4-9
ROUTINE Variables
This macro displays each of its arguments on a separate line:
?TACL MACRO
#OUTPUT %1% == Output the current argument
[#IF NOT [#EMPTY %2 TO *%] == Test for additional arguments
|THEN| %0% %2 TO *% == Call self with first arg. gone
]
ROUTINE Variables
A routine variable contains TACL statements. When TACL encounters a routine, it
executes the routine and replaces the invocation with the results returned by the
routine.
TACL routines support these capabilities that are not provided by text variables or
macro variables:
•
Sophisticated argument handling capabilities (provided by the #ARGUMENT,
#MORE, and #REST built-in functions)
•
Generation of the routine’s own expansions (provided by the #RESULT built-in
function)
•
Multiple exit points (provided by the #RETURN built-in function)
•
Ability to handle exceptions (provided by the #EXCEPTION, #FILTER, #RAISE,
and #ERRORTEXT built-in functions)
TACL executes a routine within a separate buffer; the only result is generated by one
or more #RESULT built-in functions within the routine. The important distinction
between macros and routines is that a macro invocation returns the entire text of the
macro to be executed; a routine invocation returns only what the #RESULT function
provides.
You can perform exception handling in routines to retain control in case of error
instead of giving up control to the TACL automatic exception-handling logic. For more
information, see the TACL Programming Guide.
For more information about TACL statements, see Section 5, Statements and
Programs. For additional examples of routines, see the TACL Programming Guide.
Routine Arguments
A routine does not use dummy arguments (% n%) for its method of argument handling.
Instead, use the #ARGUMENT built-in function within the routine to examine and
validate arguments and assign their values to variables for use within the function.
#ARGUMENT checks arguments one at a time to see if they satisfy any one of a list of
argument types. For some types of arguments, such as disk files, ensure that the
argument refers to an existing object or that the argument represents a syntactically
correct name for an object. (For example, the file associated with a file name must