Previous Topic: Variable Substitution

Next Topic: Complex Variable Substitution

Undefined Variable Substitution

Undefined variables, or variables that have a null value, are eliminated from the line; therefore, you should to ensure that variables are correctly coded and will not be eliminated during the substitution process. For example, the following statement:

&WRITE DATA=The time is &TIMW and date is &DATE1

incorrectly contains the variable &TIMW where &TIME was intended. Because &TIMW does not have an assigned value, it is eliminated from the statement; the final result written to the user's terminal is:

The time is  and date is 91.001

In certain cases, such as with an &IF statement, this elimination of variables can pose problems and result in syntax errors. Consider the following statement:

&IF &1 EQ YES &THEN &GOTO .OK

If &1 is a null value, perhaps because an operator did not enter its value after an &PAUSE, the statement after substitution appears as:

&IF EQ YES &THEN &GOTO .OK

and results in a syntax error and the procedure terminates.

A technique that can be used to avoid this is to append a constant character to the variable and, of course, to the value to which it is to be compared. For example:

&IF .&1 EQ .YES &THEN &GOTO .OK

In this case, if the variable &1 has a null value, the following statement results:

&IF .  EQ .YES &THEN &GOTO .OK

which is syntactically correct and performs as desired.

Note: When comparing numeric values, a zero (0) can be used as the constant character.

For more information about using this technique, see the &IF verb description in the Network Control Language Reference Guide.