A label may have control statements or commands following it; for
example:
-HERE &CONTINUE which indicates that the processing is to continue with the next line,
or:
-END &EXIT The &EXIT control statement indicates that the EXEC processor should
terminate execution of the EXEC and return contrel to CMS. You can also
specify a return code on the &EXIT control statement: &EXIT 6
results in a "(00006)" following the "Rn in the CMS ready message. If
you invoke a CMS command from the EXEC, you can specify that the return
code from the CMS command be used: &EXIT &RETCODE Since the &RETCODE special variable is set after each CMS command that
is executed r you can test it after any command to decide whether you
want execution to end. For example, you could use the &IP control
state.ent to test it: SIF &RETCODE NE 0 SEXIT SRETCODE "&EXIT &RETCODE" places the value of the CMS return code in the CMS ready message. You could place a line similar to the above following
each of your CMS command lines, or you could use the SERROR control statement
r
that will cause an exit as soon as an error is encountered: SERROR &EXIT &RETCODE
or you could use the &ERROR control statement to transfer control to
some other part of your EXEC: SERROR &GOTO -CHECK
-CHECK
Another way to transfer control to another line is to use the &SKIP control statement: &SKIP 10 transfers control to a line that is 10 lines below the &SKIP line. You can transfer control above the current line as well:
&IF &X NE &Y &SKIP -3
Transferring control with &SKIP is faster, when an EXEC is executing,
than it is with &GOTO
r
but modifying your EXEC files becomes more
difficult, particularly when you add or delete many lines. 104 IBM VM/370 eMS User's Guide
You can use combinations of &IF, &GOTO, and &SKIP to set up loops in
an EIEC. For example: &1 = 1
&IF &1 = 4 &GOTO -ENDPRT
PRINT FILE&I TEST A &1 = &1 + 1 &SKIP -3 -ENDPRT or, you can use the &LOOP control statement: &1 = 1 SLOOP 2 &1 > 3
PRINT FILE&I TEST &1 = &1 + 1 -ENDPRT In both of these examples, a loop is established to print the files
FILE1 TEST, FILE2 TEST, and FILE3 TEST. &1 is initialized with a value
of 1 and then incremented within the loop. The loop executes until the
value of &1 is greater than 3. As soon as this condition is met, control
is passed to the label -ENDPRT. COMPARING VARIABLE SYMBOLS AND CONSTANTS In an EIEC, you can test whether a certain condition is true, and then perform some function based on the decision. Some examples have already appeared in this section, such as: &LOOP 3 &1 EQ &Y In this example, the value of the variable &1 is tested for an equal
comparison with the value of the variable &Y. The loop is executed until
the condition (&1 equal to &Y) is true.
The logical comparisons you can make are:
Condition equiI---- EQ =
not equal NE ..,= greater than GT >
less than LT <
greater than
or equal to GE >=
less than or
equal to LE <= When you are testing a condition in an EIEC file, you can use either the
mnemonic or the symbol to represent the condition:
&IF &A LT &B &GOTO -NEXT is the same as:
&IF SA < &B &GOTO -NEXT Section 6. Introduction to the EXEC Processor 105
Previous Page Next Page