VISTA procedures allow testing of variables and branching based on the results of those tests. This capability greatly expands the usefulness of procedures.
The simplest use of IF is to mark a section of a procedure that is executed only if come condition is true. It has the form:
IF condition
Procedure lines (any number) that are executed if the
specified condition is met.
END_IF
You can also have two level branching:
IF condition
Procedure lines to be executed if the condition is true.
ELSE
Procedure lines to be executed if the condition is false.
END_IF
These may be strung together:
IF condition_1
Procedure lines to be executed if condition_1 is true.
ELSE_IF condition_2
Procedure lines to be executed when condition_1 is
false and condition_2 true.
...
ELSE_IF condition_N
Procedure lines to be executed when all conditions
are false except condition_N.
ELSE
Procedure lines to be executed if and only if
all other conditions are false.
END_IF
The conditions tested by the IF and ELSE_IF statements are really just VISTA arithmetic expressions. An expression is considered to be true if it evaluates to be non-zero, and false otherwise. VISTA arithmetic supports various logical operators whose value is either 1 or 0 depending on whether the logical test is true or false. The logical operators are the following, where A and B can represent single VISTA variables or algebraic expressions.
The ELSE_IF command also must have a condition to be tested on the same line. ELSE_IF's are optional, but permit you to test other conditions and execute other blocks of the procedure buffer in the event that the initial IF or any preceding ELSE_IF's are false. In this way you can allow VISTA to 'trickle down' through several tests looking for one that is true.
The ELSE statement is also optional and marks a set of procedure lines for VISTA to execute if and only if the initial IF and any following ELSE_IF's all test out false. Basically, the IF, any ELSE_IF's, or any ELSE statements all mark out various blocks of the procedure to be executed under different conditions. After the execution of any block, VISTA transfers control to the procedure lines following the END_IF statement.
IF blocks can be nested within other IF blocks up to 15 levels deep. IF blocks can be jumped out of, but not into, by the GOTO command. IF blocks must contain or be contained within DO loops completely. Some examples of IF blocks are given below:
IF X>Y
Do these procedure lines if X is greater than Y
END_IF
IF (X>Y)&(X<Z)
Do these procedure lines if X is greater than Y but less than Z.
ELSE
Otherwise jump to these procedure lines.
END_IF
IF SKY-LIMIT>BACKGRND
Do these procedure lines if IF test true.
ELSE_IF BACKGRND==0
Do these procedure lines if IF test is false,
but the ELSE_IF condition is true.
END_IF
IF IMAGE-1
Do these procedure lines if IMAGE is not equal
to 1 (which would make the expression evaluate to 0)
END_IF