To suppress hexadecimal conversion during an EXEC procedure after
having used it, you can use the EXEC control statement: &HEX OFF so you can U$e tokens containing the characters X' without the EXEC processor converting them to hexadecimal. Arguments
An argument in an EXEC procedure is one of the special variable symbols
&1 through &30 that are assigned values when the EXEC is invoked. Por example, if the EXEC named LINKS is invoked with the line:
links viola ariel oberon
the tokens VIOLA, ARIEL, and OBERON are arguments and are assigned to
the variable symbols &1, &2, and &3, You can pass as many as 30 arguments to an EXEC procedure; thus the
variable sy.bols you can set range from &1 to &30. These variables are
collectively referred to as the special variable &n. Once these symbols
are defined, they can be used and manipulated in the same manner as any
other variable in an EXEC. They can be tested, displayed, changed, and,
if they contain numeric quantities, used arithmetically. &IP &2 EQ PRINT &GOTO -PR
&TIPE &1 IS AI INVALID ARGUMENT &1 = 2
&CT = &1 ... 100 The above illustrate some explicit methods of manipulating the
&n variables. They can also be implicitly defined or redefined by two EXEC control statements: &ARGS and &READ ARGS. An &ARGS control statement redefines all of the special &n variables.
The statement: &ARGS ABC
assigns the value of A, B, and C to the variables &1, &2, and &3 and
sets the remaining variables, &4 through &30, to blanks. You can also redefine arguments interactively by using the &REID IRGS control statement. When EXEC processes this statement, a read request is
presented to your ter.inal, and the tokens you enter are assigned to the
&n variables. For example, the lines:
&TIPE ENTER FILE NAME AND TYPE: &READ ARGS STATE &1 &2 *
request you to enter
arguments &1 and &2.
blanks.
tvo tokens, and then treat these tokens as the
The remaining variables &3 through &30 are set to
If you want to redefine specific &n variables, and leave the values
of others intact, you can either redefine the individual variables in
separate assignment statements, or use the variable symbol in the SIRGS or &READ IRGS statement. For example, the statement: &ARGS CONT &2 &3 RETURN &5 &6 &7 &8 &9 &10 272 IBM VM/370 CMS User's Guide
assigns new values to the variables &1 and &4, but does not change the
existing values for the remaining symbols through &10.
If you need to set an argument or &n special variable to blanks,
either on an EXEC command line or in an SlRGS or SREAD IRGS control
statement, you can use a percent sign in its place. For example, the
lines:
&ARGS SET QUERY I TYPE &TYPE &1 &2 &3 &4
result in the display:
SET QUERY TYPE The symbol &3 has a value of blanks, and as a null token, is discarded
from the line. USING THE &INDEX SPECIAL VARIABLE The EXEC special variable, &INDEX, initially contains a numeric value
correspondinq to the number of arguments defined when the EXEC was The-value of &INDEX is reset whenever an &ARGS or &READ ARGS control statement is executed. SINDEX can be useful in many circumstances. If you create an EXEC that may expect any number of arguments, and you are going to perform
the same operation for each, you might set a counter and use the value
of &INDEX to test it. For example, an EXEC named PRINTX accepts
arguments that are the filenames of ASSEMBLE files:
&CT = 1 &LOOP 2 &CT > &INDEX PRINT &&CT ASSEMBLE &CT = &CT + 1
In the preceding example, the token &CT is substituted with &1, &2, and
so on until all of the arguaents entered on the PRINTX line are used. You can also use &INDEX to test the number of arguments entered. If
you design an EXEC to expect at least two arguments, the procedure might
contain the statements:
&IF &INDEX LT 2 &GOTO -ERR1
-ERR1 &TYPE INVALID COMMAND LINE &EXIT 1
In this example, if the EXEC is invoked with one or no arguments, an
error message is displayed and the EXEC terminates processing with a
return code of 1.
As another example, suppose you wanted to supply an EXEC with default
arguments, which might or might not be overridden. If the EXEC is
invoked with no arguments, the default values are in effect; if it is
invoked with arguments, the arguments replace the default values:
Section 14. Building EXEC Procedures 273
Previous Page Next Page