IF


The IF statement compares the contents of two fields, or compares the contents of a field with a constant, and sets the next level of the internal true/false flag.

    ••••• IF       ••• •••••••••••••••••••••• ••• •• ••• •••••••••••••••••••••• •••
    (1)            (2) (3)                    (4) (5)(6) (7)                    (8)

(1) T/F execution conditions

(5) Relation (LT,GT,LE,GE,EQ,NE,IN,EX)

(2) 1st application ID

(6) 2nd application ID

(3) 1st field name or PDF

(7) 2nd field name, PDF, or constant

(4) 1st occurrence (constant/index)

(8) 2nd occurrence (constant/index)

Sets True/False Status Indicator

In comparing the contents of two fields, or a field with a constant, the next level of the true/false status indicators is set to T if the condition is true, or F if the condition is false. See Chapter 4-2: True/False Status Indicators for details on using these indicators.

Using the Statement

The IF statement specifies a relationship between two values. The valid relational operators are:

·    less than (LT), greater than (GT), less than or equal to (LE), greater than or equal to (GE)

·    equals (EQ), not equal to (NE), includes (IN), and excludes (EX).

The relation IN means “includes”. The relation is true if the value in the second field is included in the first field, and false otherwise. If the relation is true, the predefined field TEXT AT POSITION is set to the starting position of the second field within the first field. The first field must be an alpha field; the second can be either an alpha field or a constant. Trailing blanks are ignored if the second field is a constant; however, you may specify fixed spaces (by entering underscores) to include one or more trailing spaces as part of a character string that is being searched.

Restrictions

The IF statement supports comparisons between like data types only (alpha-to-alpha, numeric-to-numeric, date-to-date, logic-to-logic). When comparing two date fields, results can be unpredictable if you are using a date field without a century component. Confirm that your System Administrator has set up the Pivot Year environment variable to avoid unexpected results.

Related PDFs

TEXT AT POSITION

Related Statements

AND, OR

Example

In this example, if the customer's balance is greater than his credit limit, an error message is given and the balance field blinks; otherwise, no action is taken.

          IF       TAR CUSTOMER BALANCE           GT TAR CUSTOMER CREDIT LIMIT
    T     ERROR    Customer's balance exceeds credit limit!

    T     BLINK    TAR CUSTOMER BALANCE