IF [ HP Data Entry and Forms Management System (VPLUS/V) ] MPE/iX 5.0 Documentation
HP Data Entry and Forms Management System (VPLUS/V)
IF
Used to execute any of the processing statements only under certain
conditions.
Syntax
IF condition THEN [statement] [statement] . . . [statement]
[ELSE [statement]]
[[statement] ]
[. ]
[. ]
[. ]
[[statement] ]
where condition is:
[constant ]
[field ]
[save field ] editstatement
[expression ]
[(indexretrieve)]
Parameters
condition A condition specified in an IF statement can be any edit
statement described below. The edit statement can be
preceded by a constant, a field name, a save field name,
an expression, or an index retrieve operand within
parentheses. Refer to "Statement Syntax" earlier in
this section for details. If an operand precedes the
edit statement, that value is tested; otherwise, the
value of the current field is tested.
If editing statement passes, then the condition is true.
If it does not, then the condition is false. Note that
this differs from interpretation of a standalone edit
statement, which causes the field to return an error and
stops field processing if the data fails the edit. Only
edit statements can be used in conditions.
editstatement A condition specified in an IF statement can be any edit
statement MATCH and CDIGIT
statement Any of the processing statements can be executed
conditionally depending an the run-time interpretation
of the specified condition. Refer to the syntax rules
below.
Discussion
An IF statement consists of two groups of statements: the THEN part and
the ELSE part. Either may have no statements associated with it. The
THEN part may include statements on the same line as THEN, plus
statements indented from the IF on immediately following lines. An ELSE
statement at the same level of indentation as the IF corresponds to that
IF. Like the THEN part, the ELSE part can have statements on the same
line, plus statements on immediately following lines that are indented
from it. Nested IF statements must be indented from each enclosing IF,
but otherwise follow the same rules. Table 4-11 illustrates some
variations on the IF statement according to the syntax rules, which are:
* No more than one IF or ELSE statement may appear on the same line.
* When non-IF statements follow either the THEN or the ELSE, they may
be on the same line as the THEN or ELSE. Statements can be separated
from each other by an optional semicolon (;).
* The entire ELSE portion of the statement may be omitted. In such a
case, no statement is executed if the condition is false. If ELSE is
included, it must be the first statement following the THEN part that
is at the same level of indentation as its corresponding IF.
* Nested IF statements are allowed. They must maintain nested
indenting.
* When nested IF statements are specified, they must be indented. The
indenting is essential for multiple statements to identify the scope
of the THEN part, as well as the ELSE part.
* An IF statement (including the THEN and ELSE part) must not cross
phase boundaries. (Refer to "Phases" later in this section.)
Example
IF QUANTITY GT If the current value of the field QUANTITY is greater
100 THEN... than 100, any statements in the THEN part at the same
level are executed.
IF NE $EMPTY If there is a value in the current field (it is not
THEN... blank), then any statements in the THEN part are
executed.
IF SAV1 IN If the value of the save field is within the range 12
12:50,100:120 through 50 or 100 through 120, then any statements
THEN... associated with THEN are executed.
IF MINLEN 1 If at least one character was entered in the current
THEN... field, execute any statements associated with THEN.
Table 4-11. Variations on the IF Statement
---------------------------------------------------------------------------------------------
| | |
| Variation | Description |
| | |
---------------------------------------------------------------------------------------------
| | |
| IF condition THEN statement | Simple IF statement. If condition is true, |
| | then statement is executed; if false, then |
| | statement is not executed. |
| | |
---------------------------------------------------------------------------------------------
| | |
| | If condition is true, all three statements |
| IF condition THEN | are executed in the order specified. If |
| statement | condition is false, none of the three |
| statement | statements is executed. |
| statement | |
| | |
---------------------------------------------------------------------------------------------
| | |
| IF condition THEN statementA | If condition is true, statementA is |
| ELSE statementB | executed; otherwise, statementB is |
| | executed. |
| | |
---------------------------------------------------------------------------------------------
| | |
| | The statementA, statementB and statementC |
| IF condition THEN statementA | are executed if the condition is true; |
| statementB statementC | statementD is executed if the condition is |
| ELSE statementD | false. |
| | |
---------------------------------------------------------------------------------------------
| | |
| | If condition is true, statementA, |
| IF condition THEN statementA | statementB, and statementC are executed; |
| statementB | otherwise statementD is executed. |
| statementC | |
| ELSE statementD | |
| | |
---------------------------------------------------------------------------------------------
| | |
| | Only if condition1, condition2 are both |
| IF condition1 THEN | true, statementA, statementB are executed. |
| IF condition2 THEN | |
| statementA | |
| statementB | Only if condition1, condition3 are true, |
| ELSE | but condition2 is false, is statementC |
| IF condition3 | executed. |
| statementC | |
| statementD | Only if condition1 is true, regardless of |
| ELSE | whether condition2, condition3 are true, is |
| statementE | statementD executed. |
| | |
| | Only if condition1 is false, is statementE |
| | executed. |
| | |
---------------------------------------------------------------------------------------------
MPE/iX 5.0 Documentation