Saving Levels Of Variables; Figure 2-4. Processing Macro Arguments - HP TACL Programming Manual

Tandem advanced command language
Table of Contents

Advertisement

Developing TACL Programs
Defining Program Structure

Saving Levels of Variables

2–8
Use the macro in Figure 2-4, defaultvars, to assign data to a set of empty variables.
The macro accepts a space-separated list of variables and nonempty values and calls
itself repeatedly until all arguments are processed. To run this macro, load the file that
contains the macro definition and then type:
12> defaultvars [ variable constant [ variable constant ...] ]

Figure 2-4. Processing Macro Arguments

?SECTION defaultvars MACRO
== Any more pairs?
[#IF NOT [#EMPTY %1%] |THEN|
== Is this variable empty?
[#IF [#EMPTYV %1%] |THEN|
== The variable is empty; install default value
#SET %1% %2%
]
== Call self again, omitting the current pair.
%0% %3 TO *%
]
The following session shows how defaultvars works:
15> #PUSH a b c
16>
defaultvars a 3 b 4 c 5
17> #OUTPUTV a
3
18> #OUTPUTV b
4
19> #OUTPUTV c
5
The #PUSH built-in function creates a new level for a user-defined or built-in variable.
If you push a variable twice, TACL creates two levels of the variable. A new level
remains in existence until you request a #POP, #UNFRAME, or #RESET FRAMES
operation.
The following code redefines the TACL OUT file, retrieves information from the
history buffer, saves the history information in a file named HISTFILE in the current
subvolume, and then restores the OUT file to its previous setting:
?SECTION historysave MACRO
#PUSH #OUT
#SET #OUT histfile
#HISTORY
#POP #OUT
107365 Tandem Computers Incorporated
== Create a new level for #OUT
== Set OUT to HISTFILE
== Retrieve history information
== Restore #OUT to its previous value

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents