HP Data Entry and Forms Management System (VPLUS) Reference Manual (32209-90024)

172 Chapter4
Advanced Forms Design
IF
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-10.
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 to a maximum of eight levels of nesting. 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.
•AnIF statement (including the THEN and ELSE part) must not cross phase boundaries.
(Refer to "Phases" later in this section.)
Example
IF QUANTITY GT 100 THEN… If the current value of the field QUANTITY is greater than
100, any statements in the THEN part at the same level are
executed.
IF NE $EMPTY THEN… If there is a value in the current field (it is not blank), then
any statements in the THEN part are executed.
IF SAV1 IN 12:50,100:120 THEN… If the value of the save field is within the range 12
through 50 or 100 through 120, then any statements
associated with THEN are executed.
IF MINLEN 1 THEN… If at least one character was entered in the current field,
execute any statements associated with THEN.