&IP &1 EO PRINT &GOTO -PRINT
&IP &1 EO TYPE &GOTO -TYPE -PRINT &EXIT -TYPE &EXIT you ensure that once the path through the -PRINT routine has been taken,
the EXEC does not continue processing with the -TYPE routine.
The &EXIT control statement also provides a special function that allows
you to pass a return code to CftS or to the program or EXEC that called
this EXEC. You specify the return code value on the &EXIT control
statement as follows: &EXIT 4 Execution of this line results in a return to CftS with a ready aessage:
R (00004) ;
If you have a variety of exits in an EXEC, you can use a different value
following each &EIIT statement, to indicate which path had been taken in
the EXEC. You can also use a variable symbol as the value to be passed as the
return code: &EXIT &VAL Another common use of the &EIrT statement
taken following an error in a CMS command,
fro. the CftS coamand in the &EIIT statement:
&IP &RETCODE NE 0 &EIrT &RETCODE
Terminal Communications
is to cause an exit to be
and using the return code You can design EIECs to be used interactively, so that their execution
depends on information entered directly from the terminal during the
execution. With the &TIPE statement, you can display a line at the
terminal, and with the &READ statement, you can read one or more lines
from the terminal or console stack. Used together, these statements can
provide a prompting function in an EXEC: 284 IBM Vft/370 CMS User's Guide
&TYPE WHAT DO YOU WANT TO DO NOW? &TYPE ENTER (STOP CONTINUE REPEAT) :
&READ VARS &LABEL &GOTO -&LABEL -STOP -CONTINUE -REPEAT In this example, the &READ control statement is used with the VARS operand, which accepts the words entered at the terminal as values to be
assigned to variable symbols. If the word STOP is entered in response to
the &READ VARS statement in this example, the variable symbol &LABEL is
assigned the value STOP. Then, in the &GOTO statement, the symbol is
substituted with the value STOP, so the branch is taken to the label -STOP. You can specify up to 17 variable names on an &READ VARS control
statement. If you enter fewer words than are expected, the remaining
variables are set to blanks. If you enter a null line, any variable
sy.bols on the &READ line are set to blanks. If the execution of your EXEC depends on a value entered as a result of an &READ VARS, you might
want to include a test for a null line immediately following the
statement; for example:
&READ VARS &TITLE &SUBJ &IF .&TITLE = • &EXIT 100 If no tokens are entered in response to the terminal read request, the
variable &TITLE is null, and the EXEC terminates with a return code of 100. If you are writing an EXEC that may receive a number of tokens from
the terminal, you may find it more convenient to use the &READ IRGS form
of the &READ control statement. When the &READ lRGS statement reads a
line from the terminal, the tokens entered are assigned to the 8n special variables (&1, &2, and so on).
READING CMS COMMANDS AND EXEC CONTROL STATEMENTS FROM THE TERMINAL When you use the &READ control statement with no operands, or with a
numeric value, EXEC reads one line or the specified number of lines from
the terminal. These lines are treated, by EXEC, as if they were in the EXEC file all along. For example, if you have an EXEC named COMMAND that
looks like the following: &TYPE ENTER NEXT COMMAND: &READ 1 &SKIP -2
all the commands you enter during the terminal session are processed by
the EXEC. Each time the &READ statement is executed, you enter a CMS command. When the com.and finishes, control returns to EXEC, which
pro.pts you to enter the next command. Since the CMS commands are all
Section 14. Building EXEC 285
Previous Page Next Page