TACL Reference Manual
Statements and Programs
HP NonStop TACL Reference Manual—429513-018
5-10
Program Structure
Program Structure
When you write a TACL program, you define the program as a type of TACL variable.
There are four types of variables that can contain executable statements: TEXT,
MACRO, ROUTINE, and ALIAS. A program can contain of one or more TACL
statements:
•
A directive, ?TACL or ?SECTION, that indicates that the following lines define a
program.
•
A #FRAME call that defines a local environment.
•
A series of #PUSH or #DEF statements that define data variables and
subprograms. (TACL does not require you to place definitions at the start of a
program, but placing definitions at the start can increase readability of the
program.)
•
Additional TACL statements; the main body of the program.
•
An #UNFRAME or #RESET FRAMES call if the program called #FRAME earlier.
TACL is an interpretive language; you do not compile or bind TACL programs. TACL
programs execute as part of your interactive TACL process unless you direct them to
run independently (in the background).
Sample Program
This program, of type macro, purges a file:
?TACL MACRO
#FRAME == Establish a local environment for variables
#PUSH err == Declare a variable called "err"
== Set err to the result of the #PURGE function:
#SET err [#PURGE %1%]
== Display the results of the purge operation:
[#IF NOT err |THEN|
#OUTPUT Purge of file %1% complete!
|ELSE|
#OUTPUT Error [err]
]
#UNFRAME == Delete the local environment
A macro accepts positional arguments; %1% refers to the first argument supplied when
you run the program.
To run this program, type the name of the file that contains the TACL statements,
followed by the name of an existing file that you want to purge. If, for example, the
statements are stored in a file called PRG, you would type this to purge a file called
TEMP:
18> PRG TEMP
Purge of file TEMP complete!
19>