An Annotated Edit Macro
The edit macro shown below, $DOUBLE, can be used to double space a C!S file. Regardless of where the current line pointer is, a blank line is
inserted in the file following every existing line. The statements in
the edit macro are separated into groups; the number to the left of a
statement or group of statements indicates an explanatory note. The
numbers are not part of the EIEC file.
1 &CONTROL OFF 2 &IF &INDEI 1 &IF &1 = ? &GOTO -TELL
3 &IF &INDEI =
1 &IF &1 = TWO &GOTO -LOOP 4 &IF &INDEI NE o &GOTO -TELL
5 &IF &READFLAG EQ STACK &READ VARS &GARB
6 &STACK &STACK PRESERVE &STACK VERIFY OFF 7 &STACK BOTTOM &STACK I IIIIXXII &STACK TOP Notes:
-1---The &CONTROL statement suppresses the display of CMS coamands, in
2
3
4
5
6
7
this case, the DESBUF command.
The first &IF checks that there is only one operand passed in the $DOUBLE command. The second &IF checks whether $DOUBLE has been
invoked with a question mark (1). If both &IFs are true, control
is passed to the statement at the label -TELL. &TYPE control
statements at -TELL explains what the macro does.
The second &IF statement checks whether $DOUBLE has been invoked
with the argument TWO, which indicates that the macro has executed
itself, so the subcommands that initialize the file are stacked
only once.
There are three ways to properly invoke this edit macro: with a 1,
with the argument TWO, or with no arguments. The third &IF
statement checks for the (no arguments) condition; if the aacro is
invoked any other way, control is passed to the label -TELL, which
explains the macro usage.
The &READFLAG special variable is checked. If $DOUBLE is executed
at the top or at the end of the file, the token TOF or EOF is in
the stack, and should be read out.
A null line is placed in the console stack for loop control (see
Note 9.) The PRESERVE and VERIFY subcommands are stacked so that
the editor does not display each line in the file as it executes
the stacked subcommands.
The BOTTOM, INPUT, and
placing a marker at the
the current line pointer TOP subcommands initialize the file by
bottom of the file, and then positioning
at the top of file.
318 IBM VM/370 CMS User's Guide
8 -LOOP &BEGSTACK NEXT STACK 1 INPUT &END
9 &READ ARGS &IF .&1 = . &SKIP &IF &1 EQ XXXXXIIX &SKIP 2 10 -ENDLOOP &STACK $DOUBLE TWO 11 &EXrT 12 DESBUF &BEGSTACK UP 2
DEL 3 TYPE RESTORE &END &EXIT 13 -TELL
&IF &READFLAG EQ STACK &READ VARS &BEGTYPE CORRECT FORM IS: $DOUBLE THIS EXEC DOUBLE SPACES A FILE BY INSERTING A BLANK LINE FOLLOWING EVERY LINE IN THE FILE EXCEPT THE LAST. SEND 8 The NEXT, STACK, and INPUT subcommands are going to be repeated for
each line in the file. The INPUT subcommand with no data line
stacks a null line. Note that in order for $DOUBLE to execute this
subcommand properly, $DOUBLE EXEC must have fixed-length records.
Each line is stacked, with the STACK subcommand; this stacked line
is checked in the read loop (Note 9). When the stacked line is
equal to the marker, XXXXXXXX, it indicates that the end of the
file has been reached. 9 These lines check for an end of file, which occurs when the line
containing the marker is read. The first time this loop is
executed, the stack contains the null line (statement 6), so the
check for the marker is skipped. 10 The last subcommand stacked is $DOUBLE TWO, which re-invokes $DOUBLE, but causes it to skip the first sequence of subcommands.
11 The &EXIT statement causes an exit from $IOUBLE, so that all the
EDIT subcommand stacked thus far are executed.
12 When the marker is read in, the EIEC clears the stack, moves the
current line pointer to point to the null line added above the
marker, and deletes that line, the marker, and the null line that
was inserted following the marker. The RESTORE subcommand restores
editor settings.
13 This edit macro is self-documenting. If $DOUBLE is invoked with a
question mark, or invoked with an argument, information regarding
its proper use is displayed. Section 17. Writing Edit Macros 319
Previous Page Next Page