executes successfully, because when each statement is scanned, the token -PROBABLY is truncated to the same eight-character token, -PROBABL. A label name may be the object of an SGOTO or SLOOP control
statement. A label that is branched to must be the first token on a, line. It
may stand by itself, with no other tokens on the line, or it may precede an executable CMS command or EXEC control statement.
The following are examples of the correct use of labels: SGOTO -LABl -LABl -LAB2 SCONTIBUE -CHECK SIF SINDEX EQ 0 SGOTO -EXIT SIF SINDEX LT 5 SSKIP -EXIT SEXIT 4 STYPE SLITERAL SINDEX VALUE IS SINDEX CONDITIONAL EXECUTION WITH THE SIF STATEMENT The main tool available to you for controlling conditional execution in
an EXEC procedure is the SIF control statement. The SIF control
statement provides the decision-making ability that you need to set up
conditional branches in your EXEC procedure. One approach to decision-making with the SIF control statement is to
compare two tokens, and perform some action based on the result of the
co.parison. When the comparison specified is equal (or true), the
executable statement is executed. When the comparison is unequal (or
false), control passes to the next sequential statement in the EXEC procedure. An example of a simple SIF statement is: SIF Sl EQ S2 STYPE MATCH FOUND If the comparand values are not equal, the statement STYPE MATCH FOUND is not executed, and control passes to the next statement in the EXEC procedure. If the co.parand values are equal, the statement STYPE MATCH FOUND is executed before control passes to the next statement. SIF statements can also be used to establish a comparison between a
variable and a constant. For example, if a terminal user could properly
enter a YES or NO response to a prompting message, you could set up SIF statements to check the response as follows: SREAD ARGS SIF Sl EQ YES SGOTO -YESANS SIF Sl EQ NO SGOTO -NOANS STYPE S1 IS NOT A VALID RESPONSE (MUST BE YES OR NO) SEXIT -YESANS -NOANS In this example, the branch to -YESANS is taken
argument is YES; otherwise, control passes to the next
276 IBM VM/370 eMS User's Guide
if the entered SIF statement.
The branch to -NOANS is taken if the argument is NO; otherwise, control
passes to the &TIPE statement, which displays the entered argument in an
error message and exits.
The test performed in an &1F statement need not be a simple test of
equality between two tokens; other types of comparisons can be tested,
and more than two variables can be involved. The tests that can be
performed and the symbols you can use to represent them are: = EQ A equals B NE A does not equal B
< LT A is less than B
<= LE A is less than or equal to B (not greater than)
> GT A is greater than B
)= GE A is greater than or equal to B (not less than) You can place multiple &IF control statements on one line, to test a
variable for more than one condition. For example, the statement:
&IF &NUM GT 5 &IF LT 10 &TIPE O.K. checks the variable symbol &NUM for a value greater than 5 and less than 10. If both of these conditions are the SIF statement is
true, and the &TIPE statement is executed. If either condition is false,
then the &TYPE statement is not executed. The number of &IF statements that may be nested is limited only by
restrictions placed on the record length of the EXEC file. BRANCHING WITH THE &GOTO STATEMENT The &GOTO control statement allows you to transfer control within your EXEC procedure: To a specified EXEC label somewhere in the EXEC file: &GOTO -TEST
where -TEST is the label to which control is passed. To a particular line within the EXEC file. For example: &GOTO 15
results in control being passed to statement 15 in the EXEC file. Directly to the top of the EXEC file. For example: &GOTO TOP passes control to the beginning of the EXEC procedure.
section 14. Building EXEC Procedures 277
Previous Page Next Page