&BEGSTACK CASE M RECFM V &END &EXIT If this were an EXEC file named $VARY, you might execute it from the
edit environment as follows:
edit test file NEW FILE.
EDIT:
$vary Stacked subcommands are executed only when the EXEC completes its
execution, either by reaching the end of the file, or by processing an &EXIT statement. When you stack EDIT subcommands, you can use the &STACK and &BEGSTACK control statements. If you are stacking a subcommand that uses a
variable expression, you must use the &STACK control statement, rather
than the &BEGSTACK control statement. The following EXEC, named $T,
displays a variable number of lines and then restores the current line
pointer to the position it was in when the EXEC was invoked: &CONTROL OFF
&IF &INDEX EQ 0 &GOTO -ERR &CHECK = &DATATYPE &1
&IF &CHECK NE NUM &GOTO -ERR &STACK TYPE &1 SUP = &1 -1 &STACK UP SUP &EXIT -ERR &TYPE CORRECT FORM IS < $T N > &EXIT 1
This edit macro uses the built-in function &DATATYPE to check that a
numeric operand is entered. CMS commands in an edit macro are executed as they are read by the EXEC interpreter, just as they would if the EXEC were invoked in the CMS environment. You could create a $TYPE edit macro, for example, that
would allow you to display a file from the edit environment: &CONTROL OFF TYPE &1 &2 &3 &4 &5 &6 &1
Or you might create a $STATE EXEC that would verify the existence of
another file: &CONTROL OFF STATE &1 &2 &3
In both of these examples, the macro file invokes the CMS command.
Macros like these can eliminate having to enter CMS subset environment
to execute one or two simple CMS commands. You must be careful, though,
not to execute any CMS command that uses the storage occupied by the
editor. Only commands that are valid in CMS subset are valid in an edit
macro.
312 IBM VM/310 eMS User's Guide
THE CONSOLE STACK When you write an edit macro, you want to be sure that there are no EDIT
subcommands in the stack that could interfere with the execution of the
subcommands stacked by the macro file. Your macro should check whether
there are any lines in the stack, and if there are, it should clear them
from the stack. For example, you might use the lines:
&IF &READFLAG EQ CONSOLE &SKIP 2 DESBUF &TYPE STACKED LINES CLEARED BY &0 The message "STACKED LINES CLEARED BY macro name" is issued by the edit
macros distributed with the VM/310 system. You may also want to use
this convention in your macros, to alert a user that the console stack
has been cleared. When an edit macro is invoked and the current line pointer is positioned
at the top of the file or at the end of the file, the editor stacks a
token in the console stack. If the line pointer is at the top of the
file, the token stacked is "TOF"; if the line pointer is at the end of
the file the token stacked is "EOF". If you write an edit macro that
does not check the status of the console stack, and the macro is invoked
from the top or the end of the file, you receive the message:
1EDIT: TOF or:
1EDIT: EOF The editor does not recognize these tokens as valid subcommands. You may want to use these tokens to test whether the EXEC is invoked from the top or end of the file. If you want to clear these tokens in
case the macro has been invoked from the top or end of the file, you
might use the statement:
&IF &READFLAG EQ STACK &READ ARGS which clears the token from the stack.
If you do not want to clear the console stack when you execute an edit
macro, you can stack all of the subcommands using the LIFO (last-in
first-out) operand of the &STACK and &BEGSTACK control statements. For
example, suppose $FORMAT is the name of the follcwing edit macro: &BEGSTACK LIFO TABSET 3 10 11 TRUNC 71 PRESERVE &END Section 11. Writing Edit Macros 313
Previous Page Next Page