If this EXEC is named EDEX, and you invoke it with:
edex frOl the BDIT subcommands are stacked in the order they appear in the EXEC. The EDIT command is invoked to edit the file FROl DATA, and the EDIT
subcommands are read from the stack and executed. When the stack is eapty, your virtual machine is in the edit environment in input mode,
and the first line you enter replaces the existing line that contains
the character string xx.
Note that all of the EDIT subcommands in the example, except for the REPLACE subcommand, are stacked within an SBBGSTACK stack, and that the REPLACE subcommand is stacked with SSTACK. If you are creating EXEC files with fixed-length records, you must use SSTACK to stack the INPUT and REPLACE subcommands. If you use SBEGSTACK, then the INPUT and
REPLACE subcommands are treated as if they contain text data, and so
insert or replace one line in the file (a line of This is not
true, however, for variable-length EXEC files.
Similarly, if you want to stack a null line, to change from input mode to edit mode in an EXEC, you must use the SSTACK statement with no
other data on the line (in both fixed-and variable-length EXEC files),
for example: SSTACK INPUT SBEGSTACK ••• data line ••• data line ••• data line SEND SSTACK SSTACK FILE
EDIT Sl S2 SEXIT When this EXEC is invoked with a filename and filetype as arguments, the INPUT subcommand, data lines, null line, and FILE subcommand are placed
in the stack before the EDIT command is issued. The data lines are
placed in the specified file and the file is written onto disk before
the EXEC returns control to CMS. STACKING LINES FOR EXEC TO READ
Lines in the console stack can be read by the FXEC interpreter with an SREAD control statement; for example: -SETUP SLOOP 3 SNUft = 50 SSTACK SNUM SCHAR SNUft = SlUM + 1 SCHAR = SCONCAT SSTRNG SNU8 -READ SLOOP -FINIS SREADFLAG EQ CONSOLE SREAD ARGS -FINIS
Paqe of GC20-1819-2 As Updated April 1, 1981 by TNL GN25-0826
In this EXEC procedure, the statements following the label -SETUP stack
a namber of lines. The variables &NUM and &CHAR are substituted before
they are stacked. At the label -READ, the lines are read in from the
stack and processed. The values stacked are read in as the variable
symbols &1 and &2. Control passes out of the loop when the stack is empty. CLEARING THE CONSOLE STACK If you ase the console stack in an EXEC procedure, you should be sure
that it is empty before you begin stacking in it. Also, you
should be sare that it is empty before exiting from the EXE: (unless you
have parposely stacked CMS commands for execution).
to clear a line from the stack without affecting the your EXEC is to use the &READ VARS or &READ ARGS control You can use &READ VARS without specifying any variable One way execution of
statement.
symbols so
example:
that the line read is read in and effectively ignored. For &LOOP 1 &READFLAG EQ CONSOLE &READ ARGS If these lines occur at the beginning of an EXEC file, they ensure that
any stacked lines are cleared. If the EXEC is named EXE:1 and is
invoked with the line: execlitype help memoitype print memo then the lines TYPE HELP MEMO and TYPE PRINT MEMO are cleared from the
stack and are not executed. You =oulj use the same technique to clear the stack in case of an error encountered in your EXEC, so that the stack is cleared before retarnina to CMS. You would especially want to do this if you stacked
data lines or EXEC control statements that have no meaning to :MS. Another to clear the console stack is with the :MS function DESBUF. For example:
&IF &READFIAG EQ STACK DESBUF When yOl use the DESBUF function to clear the console input stack, the
output stack is also cleared. The output stack contains lines that are
waitinq to be displayed or typed at the terminal. Frequently, when an
EXEC is processinq, output lines are stacked, and are not displayed
immediately followinq the execution of an STYPE statement. If you want to display all pending output lines before clearing the console input
stack, yoo should use the CONWAIT function, as follows: CONWAIT &IF &READFLAG EQ STACK DESBUF The CONWAIT (console wait) function causes a suspension of program
executi)n until the console output stack is empty. If there are no lines
waiting to be displayed, CONWAIT has no effect. Clearinq the stack is important when you write edit macros, since all
subcommands issued in an edit macro must be first stacked. See "Section 17. Writing Edit Macros" for additional information on using the console
stack.
section 1U. Building EXEC Procedures 293
Previous Page Next Page