Another example of a conditional loop is: &Y = &LITERAL A&B &LOOP 2 .&X EQ &LITERAL .& &X = &SUBSTR &Y 2 1 &TYPE &X These statements are interpreted and executed as follows:
1. The variable&Y is set to the literal value A&B.
2. The two statements following the&LOOP statement are to be executed
until the value of&X is &.
3. The&SUBSTR built-in function is used to set the variable &X to the
value of the second character in the variable&Y, which is a
literal ampersand (&).
4. The ampersand is typed once, and the loop does not execute again
because the condition that the value of&X be a literal ampersand
ismet. NESTING EXEC PROCEDURES If you want to use an EXEC procedure within another EXEC, you must use
theEXEC command to execute it. For example, if you have the statement: EXEC TEST in an EXEC procedure, it invokes the EXEC procedure TEST. The procedure TEST EXEC executes independently of the other EXEC; the variables &1, &2
and so on are assigned values and the default settings for control
statements such as&CONTROL and &HEX are reset. When TEST EXEC completes execution, control returns to the next line in the calling EXEC, where the values for variable symbols and EXEC settings are the
same as when theTEST EXEC was invoked. Variables in an EXEC file have meaning only within the particular
procedurein which they are defined. There are two methods you can use
to pass variable information to nestedEXECs. One way is to pass
arguments on theEXEC command line. For examFle, if the CHECK EXEC contains the line: EXEC COUNTEft SWUM then the current values of and are assigned to the variable
symbols &1 and &2in COUNTEft EXEC. (The values of &1 and &2 in CBECK EXEC do not change.) You can also use the ten special variables &GLOBALO through &GLOB1L9. These variables can only contain integral numeric values; you cannot
assign them character-string values. These variables can be used to set
up arguments to pass to nested procedures, or to communicate betweenEXEC files at different recursion levels.
282IBM VM/370 User's Guide
1. The variable
2. The two statements following the
until the value of
3. The
value of the second character in the variable
literal ampersand (&).
4. The ampersand is typed once, and the loop does not execute again
because the condition that the value of
is
the
and so on are assigned values and the default settings for control
statements such as
same as when the
procedure
to pass variable information to nested
arguments on the
symbols &1 and &2
assign them character-string values. These variables can be used to set
up arguments to pass to nested procedures, or to communicate between
282