when this line is executed, the EXEC issues a read to your virtual
machine so that you can enter up to 30 arguments, to be assigned to the
variables &1, &2, and so on. ASSIGNMENT STATEMENTS User-defined variable names begin with an ampersand (&) and contain up
to seven additional characters,. These variables can contain numeric or
alphameric data. You define and initialize EXEC variables in assignment
statements. In an assignment statement, the first data item starts with
an ampersand (&) and the second data item is an equal sign (=). The
value of the expression on the right side of the equal sign is assigned
to the variable named on the left of the equal sign. For example:
&A = 35
is an assignment statement that assigns the numeric value 35 to the
variable symbol &A. A subsequent assignment statement might be:
&B = &A + 10 After this assignment statement executes, the value of &B would be 35
plus 10, or 45. You can use the &READ control statement to assign variable names
interactively. For example, when the statement:
&READ VARS &NAME &AGE
is executed, the EXEC issues a read to your virtual machine, and you can
enter a line of data. The first two words, or tokens, you enter are
assigned to the variable symbols &NAME and &AGE, respectively. !gte: The data item immediately following the target of an assignment
statement must be an equal sign (=) and not an EXEC variable that has
the value of an equal sign. Conversely, if an equal sign is to be the
first data item following an EXEC control word, then it must be
specified as an EXEC variable that has the value of an equal sign and
not as an equal sign; otherwise, the statement is interpreted as an
assignment statement and the control word is thereafter treated as a
variable.
If you use a variable name that has not been defined, the variable
symbol is set to a null string by the EXEC processor when the statement
is executed. For example, if you have entered only two arguments on the EXEC command line, then the statement:
&IF &3 EQ CONT &ERROR &CONTINUE is interpreted:
&IF EQ CONT &ERROR &CONTINUE &ERROR and &CONTINUE are recognized by EXEC as control statements.
Since &3 is undefined, however, it 1S replaced by blanks and the
resulting line produces an error during EXEC processing. You can
prevent the error, and allow for null arguments or variables, by 102 IBM VM/370 eMS User's Guide
concatenating some other character with the variable. A period is used
most frequently: SIF .&3 EQ .CONT &ERROR &CONTINUE If &3 is undefined when this line is scanned, the result is:
&IF • EQ .CONT &ERROR &CONTINUE which is a valid control statement line. BUILT-IN FUNCTIONS AND SPECIAL VARIABLES The EXEC built-in functions are similar to those
languages. You can use the EXEC built-in functions to
symbols in an EXEC procedure.
Figure 8 summarizes the built-in functions. It
variable &A, the values resulting in a variable &B
function is used to assign its value. Notice that all
functions are used on the right-hand side of assignment
the &LITERAL built-in function can be used in control
exallple: &TYPE &LITERAL &A
Function Usage ExamFle
&A = 123 &CONCAT Concatenates tokens into a
of higher-level
define variable
shows, given the
when a built-in
of the built-in
statements. Only statements; for
&B
single token. &B = &CONCAT &A 55 12355 &DATATYPE Assigns the data type (NUM or CHAR) to the variable. &B = &DATATYPE &A NUM &LENGTH Assigns the length of a
token to a variable. &B = &LENGTH &A 3
&LITERAL Prohibits substitution of a
variable symbol. &B = &LITERAL &A &A &SUBSTR Extracts a character string
from a token. &B = &SUBSTR &A 2 2 23
Figure 8. Sumaary of EXEC Built-in Functions FLOW CONTROL IN AN EXEC An EXEC is processed line by line: if a statement is encountered that
passes control to another line in the procedure, execution continues
there and each line is, again, executed sequentially. You can pass
control with an &GOTO control statement: &GOTO -BEGIN
where -BEGIN is a label. All labels in EXEC files must begin with a
hyphen, and must be the first token on a line. For example: -LOOP Section 6. Introduction to the EXEC Processor 103
Previous Page Next Page