Calling a Routine Recursively
Developing TACL Routines
3–16
107365 Tandem Computers Incorporated
Calling a Routine
Recursively
#The #ROUTINENAME built-in function returns the name of the currently active
routine, which allows you to invoke a routine from within the routine. The function is
similar to accessing %0% from a macro, but you cannot use #ROUTINENAME in a
macro or %0% in a routine.
If you call #ROUTINENAME for a routine defined with a ?TACL ROUTINE directive,
#ROUTINENAME returns the name of the variable TACL uses to hold the active copy
of the routine.
Use the macro in Figure 3-10,
caller
, to process one or more arguments. To use this
macro, load the associated file and enter:
caller {
file-name | TACL | TAL | PASCAL | system-name }...
Caller
calls
proc_arg
to process each argument.
Proc_arg
calls itself additional
times if there is more than one argument.
Figure 3-10. Processing Arguments
?SECTION caller MACRO
#FRAME
#PUSH e1 var1 rslt
[#IF NOT [#EMPTY %1%] |THEN|
proc_arg %*%
]
#UNFRAME
?SECTION proc_arg ROUTINE
#SET rslt [#ARGUMENT /VALUE var1/ FILENAME KEYWORD &
/WORDLIST tacl tal pascal/ SYSTEMNAME OTHERWISE]
[#CASE [rslt]
|1| == File name
FILEINFO [var1]
|2| == Keyword
#OUTPUT [#SHIFTSTRING /UP / [var1]] is a keyword
|3| == System name
#OUTPUT /HOLD/ The system number for [var1] is :
#OUTPUT [#SYSTEMNUMBER [var1]]
|4| == Word
#OUTPUT Expecting a file name, the word TACL, TAL,
#OUTPUT or PASCAL, or a system name.
#RETURN
]
[#IF [#MORE] |THEN|
#OUTPUT == blank line
[#ROUTINENAME] [#REST]
]