if
FORMULA

The if statement decides what code to execute next.


Parameters

This statement has one parameter:

formula – is a formula that decides whether or not to execute the following statements. The result of this formula must be a Boolean (true/false) value.


Description

The if statement is the basic building block for making decisions in a Panorama program . The if statement will skip over the next few statements (up to the next else, elseif or endif statement) if the true/false formula is false. Here’s a simple example.

if City=""
    City="Pismo Beach"
    State="CA"
endif
message City+", "+State

Depending on what’s in the City field, this procedure can work one of two ways. If the City field is empty, the true/false formula

City=""

will be true, so the procedure will perform the assignments

City="Pismo Beach"
State="CA"

But if the City field is not empty, the true/false formula will be false, and Panorama will skip past the endif to the message statement.

In this example there are two statements between the if and endif statements. These two statements will be skipped if the formula is false. However, there is no limit to the number of statements that may be between the if and endif statements. Just make sure that there is always a matching endif for every if. Although it is not required, indenting the statements between the if and the endif usually makes the procedure easier to read and understand.

Nested IF Statements

Pairs of if-endif statements can be nested inside each other, like this:

if State=""
   State="CA"
   if City=""
      City="Pismo Beach"
   endif
endif
message City+", "+State

There is no limit to how many levels deep you can nest if-endif pairs, but be sure that each if statement is matched by a corresponding endif statement.


Error Messages

IF or ELSE without ENDIF – Each IF statement must be paired with a corresponding ENDIF statement. If this error message appears, the necessary endif statement has not been included.


See Also


History

VersionStatusNotes
10.0No ChangeCarried over from Panorama 6.0.