HP 3000 Manuals

CALCULATED VALUES [ USING VPLUS/V AN INTRO. TO FORMS DESIGN Self-Paced Training Guide ] MPE/iX 5.0 Documentation


USING VPLUS/V AN INTRO. TO FORMS DESIGN Self-Paced Training Guide

CALCULATED VALUES 

In addition to assigning specified values to display-only fields, the SET
TO statement is also used to assign calculated values to display-only
fields.  In this case, the data type of all the fields involved in the
calculations must be numeric.  That is, their data type must be DIG,
NUM[n], or IMPn.  To illustrate, let's calculate the total cost of the
part ordered through the ORDER form.

Action 

First, locate the Field Menu for TPRICE in the ORDER form.

Since the TPRICE field is the last of 13 fields in the ORDER form, the
simplest method is to press NEXT FORM to go to the Form Menu for TOTALS,
and then press PREV to go back to the last Field Menu of the previous
form, ORDER. Or, you can go to the Main Menu, select G, the form name
(TOTALS) and the field name (TPRICE) to go to the particular field.

Action 

When the Field Menu for TPRICE is displayed, change the field type to D.
Press FIELD TOGGLE. Type the SET TO statement shown in Figure 5-7 in the
processing specification area.  Press ENTER.

The SET TO statement calculates the value of TPRICE from UPRICE and QTY.
The data type for TPRICE is already NUM2 so it need not be changed.  Note
that the data types of QTY and UPRICE are already numeric; QTY is type
DIG and UPRICE is NUM2.

As a result of this specification, the user need only enter values in the
QTY field and the UPRICE field.  When ENTER is pressed, ENTRY calculates
the total price for the TPRICE field and transfers it to the batch record
with the other data from this form.  The user does not see the calculated
value unless using Browse mode to review the data.

Any field used in a calculation must have a value when the calculation is
performed.  If it has no value, then the calculation is skipped.  In this
exercise, the values of the QTY and UPRICE fields are both required
(FType of R) so that the calculation of TPRICE is always performed.

[]
Figure 5-8. Field Menu for ORDATE in the TOTALS Form


MPE/iX 5.0 Documentation