HELP IF — VMS 4.6
Tests the value of an expression and executes the command following
the THEN keyword if the test is true.
Format:
IF expression THEN [$] command
Additional information available:
Parameters
expression Defines the test to be performed. The expression can consist of one or more numeric constants, string literals, symbolic names, or lexical functions separated by logical, arithmetic, or string operators. Expressions in IF commands are automatically evaluated during the execution of the command. All character strings beginning with alphabetic characters that are not enclosed in quotation marks are assumed to be symbol names or lexical functions, and the IF command replaces them with their current values. Symbol substitution in expressions in IF commands is not iterative; that is, each symbol is replaced only once. However, if you want iterative substitution, you can precede a symbol name with an apostrophe or ampersand. The command interpreter does not execute an IF command when it contains an undefined symbol. Instead, the command interpreter issues a warning message and executes the next command in the procedure. For a summary of operators and details on how to specify expressions, see Section 5.7 of the VAX/VMS DCL Concepts Manual. command Defines the action to take if the result of the expression is true. You can specify any valid DCL command following the THEN keyword. Optionally, you can precede the command with a dollar sign.
Examples
1. $ COUNT = 0
$ LOOP:
$ COUNT = COUNT + 1
.
.
.
$ IF COUNT .LE. 10 THEN GOTO LOOP
$ EXIT
This example shows how to establish a loop in a command procedure,
using a symbol named COUNT and an IF statement. The IF statement
checks the value of COUNT and performs an EXIT command when the
value of COUNT is greater than 10.
2. $ SET NOON
.
.
.
$ LINK CYGNUS,DRACO,SERVICE/LIBRARY
$ IF .NOT. $STATUS THEN EXIT
$ RUN CYGNUS
This command procedure uses the SET NOON command to disable error
checking by the command procedure. After the LINK command, the IF
command tests the value of the reserved global symbol $STATUS. If
the LINK command returns an error status value, the command
procedure exits.