HP Data Entry and Forms Management System (VPLUS) Reference Manual (32209-90024)
Chapter 4 135
Advanced Forms Design
Statement Syntax
parentheses are evaluated first and, if parentheses are nested, the innermost are
evaluated first. The % in the expression a%b is equivalent to (a*.01)*b. When $EMPTY is
used in an arithmetic expression, the result is always $EMPTY. Thus, $EMPTY with any
operator and operand = $EMPTY. The following examples illustrate arithmetic expressions:
F2 + 1 Add 1 to the value in field F2.
QUANTITY * UNITPRICE Multiply value in QUANTITY by value in UNITPRICE.
TOTALCENTS/ 1000 Divide value in TOTALCENTS by 1,000.
20% (TOTALPRICE - TAX) Find 20 percent of the value resulting from subtracting
TAX from TOTALPRICE.
$EMPTY + 20 The result is always $EMPTY, regardless of the operator or
other operand.
NOTE
When the VPLUS intrinsics execute an arithmetic expression, they expect
each operand in the expression to have a value; if any operand does not have
a value, the result is null. It appears to the user as if the expression had not
been executed and no message is issued.
Index Retrieve Operand
An index retrieve operand (enclosed within parentheses) can be used in any edit statement
where a constant, field, or expression is legal. An index retrieve operand without enclosing
parentheses can be used in SET and CHANGE statements.
An index retrieve operand is specified in the format:
index
OF
element [,element]
...
index is a numeric type field or save field, or a numeric expression whose value is
a positive integer. The index value indicates which element is selected.
element is a constant, field, save field, or expression. Each element in the list of
elements separated by commas must be the same type (character, numeric,
or date).
When an operand of this type is specified, its effective value is selected from a list of values
according to its position in the list, where the first element of the list is 1. First, the index
expression is evaluated, then this value is used to select a final value from the list.
For example:
EQ (N OF "ABC","DEF", "GHI", FIELDX)
If the value of N is 1, the character string "ABC" is the selected operand: if
the value of N is 4, the value of FIELDX is selected. If the value of N is
negative, zero, or greater than the number of elements, an error message
is returned. Note that the operand is enclosed in parentheses because EQ is
an edit statement.
SET TO F3 OF F1,15,20, 25,35,40
If the value of F3 is 1, the selected operand is the value of field F1; if F3 is