PS TEXT FORMAT Reference Manual

Examples of Function and Macro Constructs
G-12 11387 Tandem Computers Incorporated
1 - The name of this macro is idx. Your input to this macro either
generates a new index entry or is a command to print an index.
2 - This IF construct checks to see if there is any input (arguments in
TFORM) in your file for this macro. If there is no input or if the input
is incorrect, TFORM displays this error message and exits the macro. If
input exists and is correct, then the next macro statement is executed.
3 - This IF construct creates a counter to keep track of index entries. The
counter, idx_count, is assigned the value of zero.
4 - This IF construct is the main body of the macro. Within this IF
construct, index entries are sorted, saved, and printed. Index entries
are printed only when the keyword BUILD is found in your file. The
nested IF and LOOP constructs within this main IF construct are
flagged with A, B, C, and so forth as follows:
4A - This LOOP construct contains other constructs that sort the
index entries and store the sorted entries.
4B - This IF construct checks to see if there are any remaining index
entries to be processed.
4C - This LOOP construct determines which index entry of the
remaining entries is first in alphabetical order.
4D - This IF construct compares two index entries to put in
alphabetical order.
4E - This LOOP construct prints all index entries alphabetically with
their page numbers. The following application shows the input
file with the idx strings in place, referencing various items for
the index. The last line of the file calls the IDX macro with the
argument BUILD recognized as the keyword for building the
index.