PS TEXT FORMAT Reference Manual

Introduction to TFORM
11387 Tandem Computers Incorporated 3–97
Tips
You can’t abbreviate LOOP, NEXTLOOP, EXITLOOP, or ENDLOOP
commands or combine them with other commands; each must be on a
line by itself.
If you omit
exp
, TFORM goes into an infinite loop, which you must
explicitly terminate with an EXITLOOP command.
All the commands that make up a LOOP construct must be in a single
input file. You should, therefore, check that any LOOP construct
contained in a sourced-in file is both begun and ended in that file.
You may find the LOOP construct quite useful in performing repetitive
processing for numbers of iterations that vary with individual
circumstances. Two such circumstances are the following
1. Repeated printing of form letters (no expression in the LOOP
command, but a test after each iteration for end-of-file in the name-
and-address file followed by an EXITLOOP if that condition is true)
2. Macro processing (macros are described next) with a varying
number of arguments. For example, a macro could be designed
that clears all previously set tab stops and then sets a number of tab
stops defined by the arguments supplied, which vary with each
invocation of the macro. Within such a macro, the function ARG(0)
could supply the number of arguments present each time the macro
is called. The LOOP construct would then perform one iteration for
each argument.
You can nest loops within other loops. When you do this, the
innermost loop runs from start to finish before the next iteration of the
outer loop can begin. That loop, in turn, runs to completion during a
single iteration of the next outer loop (if any), and so on.