IFxx (If)
Free-Form Syntax | (not allowed - use the IF operation code) |
Code | Factor 1 | Factor 2 | Result Field | Indicators | ||
---|---|---|---|---|---|---|
IFxx | Comparand | Comparand |
The IFxx operation allows a group of calculations to be processed if a certain relationship, specified by xx, exists between factor 1 and factor 2. When ANDxx (And) and ORxx (Or) operations are used with IFxx, the group of calculations is performed if the condition specified by the combined operations exists. (For the meaning of xx, see Structured Programming Operations.)
You can use conditioning indicators. Factor 1 and factor 2 must contain a literal, a named constant, a figurative constant, a table name, an array element, a data structure name, or a field name. Both the factor 1 and factor 2 entries must be of the same data type.
If the relationship specified by the IFxx and any associated ANDxx or ORxx operations does not exist, control passes to the calculation operation immediately following the associated ENDIF operation. If an ELSE (Else) operation is specified as well, control passes to the first calculation operation that can be processed following the ELSE operation.
Conditioning indicator entries on the ENDIF operation associated with IFxx must be blank.
An ENDIF statement must be used to close an IFxx group. If an IFxx statement is followed by an ELSE statement, an ENDIF statement is required after the ELSE statement but not after the IFxx statement.
You have the option of indenting DO statements, IF-ELSE clauses, and SELECT-WHENxx-OTHER clauses in the compiler listing for readability. See the section on compiler listings in the Rational® Development Studio for i: ILE RPG Programmer's Guide for an explanation of how to indent statements in the source listing.
For more information, see Compare Operations or Structured Programming Operations.