AND
The AND statement adds a second or subsequent conditional check to a preceding statement, such as the series IF A is true AND B is true, then .... The AND statement itself compares the contents of two fields, or the contents of a field with a constant, to determine if a condition is true.
AND
(1)
(2) (3) (4) (5)(6)
(7) (8)
(5) Relation (LT,GT,LE,GE,EQ,NE,IN,EX) | |
(4) 1st occurrence (constant/index) |
(8) 2nd occurrence (constant/index) |
The AND statement may modify the current value of the next internal true/false status indicator. If the preceding statement is true and the AND statement is false, the current status of the next indicator is changed to F. See Using AND and OR Statements for more information.
The AND 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.
Normally, an AND statement is used immediately after an IF statement. However, the AND statement will operate successfully when used after any statement that sets the true/false status indicator. See AND and OR with Statements Other Than IF.
An AND statement may also be used in conjunction with one or more OR statements. For example:
IF
A
AND
B
OR
C
AND
D
Another example is:
IF
A
OR
B
AND
C
OR D
Each of these examples could be expanded to add more AND and OR statements in various sequences but, no matter how many there are, the rules are always the same:
· Each AND or OR statement performs only two checks at most: it checks the current value of the next true/false status indicator, and it evaluates its own condition. It does not matter how many statements preceded the AND/OR statement, nor what other statements follow the AND/OR statement.
· If the current status of the next indicator is already false, the AND statement is bypassed since it is no longer relevant. If the current status is true and the AND statement is true, the current status is left unchanged as T. However, if the AND statement is false, the current status of the next indicator is changed to F.
· Conversely, for an OR statement, if the current status of the next indicator is already true, the OR statement is bypassed since it is no longer relevant. If the current status is false and the OR statement is false, the current status is left unchanged as F. However, if the OR statement is true, the current status of the next indicator is changed to T.
The AND 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.
This example shows how to perform statement printing if the customer is not a miscellaneous customer and does not have a zero balance. If either condition is false, the level 1 true/false status indicator will be F and the subroutine to print statements will not be executed.
IF TAR
CUSTOMER MISC CUSTOMER NE 1
AND TAR
CUSTOMER BALANCE NE 0
T GOSUB :PRINT
STATEMENTS