TACL Reference Manual

Variables
HP NonStop TACL Reference Manual429513-018
4-4
Specifying a Level of a Variable
The choice of a declaration mechanism depends on whether you want to define the
variable interactively, within a file, or in a library. For more information about files and
libraries, see Section 5, Statements and Programs.
When you create a variable, TACL creates level 1 of the variable. To create additional
levels, push or define the same variable. TACL then creates a new level of the variable
and increments the level number.
You can use the #FRAME built-in function at the start of a macro or routine to define a
local environment for variables. If you create variables within a frame, you can remove
all the variables and their levels by deleting the frame with an #UNFRAME or #RESET
FRAMES operation.
A variable remains in existence unless you delete it with a #POP function call, POP
command, an #UNFRAME operation, or a #RESET FRAMES operation.
Specifying a Level of a Variable
To specify a level of a variable, append a period and a level number to its name. If you
omit the level number, TACL accesses the top level.
You can specify a level number in one of two ways:
Numbers greater than zero refer to levels relative to the bottom of the stack; they
indicate the order of creation of the levels. As an example, name.1 is the bottom
level, name.2 is the next to the bottom level, and so on.
Numbers less than or equal to zero refer to levels relative to the top of the stack;
they indicate how far down a level is from the top of the stack. Therefore, name.0
is the top level, name.-1 is the next to the top level, and so on.
This diagram shows the two ways to address levels of the sample variable var1:
Different levels can contain different types of data. For example, the first level of a
variable could contain an alias, the second level could contain text, and the third level
could contain a macro.
Bottom-Up Addressing Top-Down Addressing
var1.3 (top), also accessible as var1 XYZ var1.0
var1.2 A var1.-1
var1.1 35 var1.-2