Defining Program Structure
Developing TACL Programs
2–2
107365 Tandem Computers Incorporated
Defining Program
Structure
The following paragraphs describe topics that are related to the structure of TACL
programs:
Using flow control functions: #LOOP, #IF, and #CASE
Nesting programs within other TACL programs
Saving and restoring levels of variables
Exiting from TACL programs
Using Flow Control
Functions
The following examples show how #LOOP, #CASE, and #IF statements work.
The macro in Figure 2-1,
copier
, demonstrates two ways to perform an activity in a
loop.
Copier
makes six copies of a file named TYPE. (The file TYPE must exist
before you run
copier
.) For the first three duplications,
copier
starts a new FUP
process during each pass through a loop. For the second three duplications,
copier
loops to prepare a sequence of commands and then passes the commands to FUP. The
second method requires one additional variable and one more function call but starts
only one FUP process, and is therefore more efficient.
When you run
copier
, your TACL process must be named (using the NAME option
with the TACL command). To run
copier
, load the file that contains the macro and
then type:
copier
Figure 2-1. Performing Tasks Within a Loop
?SECTION copier MACRO
#FRAME
#PUSH listvar == List of files to be duplicated
#PUSH sn == Serial number
== Less efficient method; multiple processes started
#SET sn 0
[#LOOP |DO|
FUP DUP type, tmpa[sn] == Start FUP for each
#SET sn [#COMPUTE sn + 1] == command in the loop
|UNTIL| (sn = 3)
]
== More efficient method; one process started
#SET sn 0
[#LOOP |DO|
#APPEND listvar DUP type, tmpb[sn]
#SET sn [#COMPUTE sn + 1]
|UNTIL| (sn = 3)
]
FUP/INV listvar/ == Execute FUP only once
#UNFRAME