TRANSFER VALUES BETWEEN FORMS [ 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
TRANSFER VALUES BETWEEN FORMS
So far you transferred the same value from a save field to fields in two
different forms. Now, you use save fields to transfer values entered on
one form to another form. The two save fields, SNAME and STOTNET are
used for this purpose. The value of NAME in the ORDER form is
transferred to the SNAME save field. Then the value in SNAME is
transferred to the NAME field in TOTALS. Similarly, the value in TPRICE
of the ORDER form is transferred to the STOTNET save field, and the value
in STOTNET is subsequently moved to the TOTNET field of TOTALS. To
perform these transfers, SET statements must be added to the name and net
total fields of both the ORDER form and the TOTALS form. Start with the
NAME field in the ORDER form.
Action
Find the Field Menu for NAME and change the field type to R for required.
Then press FIELD TOGGLE to enter the processing specifications shown in
Figure 6-8. Press ENTER to record the changes.
Making NAME a required field insures that a customer name is actually
entered. Though not necessary for the transfer to TOTALS, it is good
practice to associate a customer name with each order. The SET statement
is executed in the field edit phase since no heading is specified. This
means that if the name is changed, the change is also recorded in the
save field.
Figure 6-9. The Field Menu for NAME in the TOTALS Form
Now, transfer this name to the customer name field in TOTALS.
Action
Find the Field Menu for NAME in form TOTALS, then enter the
specifications shown in Figure 6-9. Note that the field type is changed
to D for display-only so the operator cannot change the name on this
form. Press ENTER to record your changes.
Figure 6-10. Field Menu for TPRICE
Now, make similar changes to the TPRICE field of the ORDER form and the
TOTNET field of the TOTALS form.
Action
Add a statement to store the value of TPRICE in the STOTNET save field,
as shown in Figure 6-10.
Note that the order in which the processing specification statements are
entered is important. The statement to move the value to the save field
must follow the statement that calculates that value. Since both
statements are executed in the field edit phase, any change to the values
of either QTY or UPRICE in Browse mode change the value of TPRICE, which
is then moved to the STOTNET save field.
Figure 6-11. The Field Menu for TOTNET in the TOTALS Form
The last change is to the TOTNET field in form TOTALS.
Action
First, change the field type to D for display-only and then add the
statements (shown in Figure 6-11) to transfer the calculated net price
from the ORDER form. You should delete the existing formatting
statements (JUSTIFY RIGHT and STRIP LEADING "0") since the SET statement
causes this formatting to be performed automatically. Press ENTER to
record the changes.
The SET statement must also appear in the FIELD phase to insure that the
net total is updated if changes are made in Browse mode. Statements in
the INIT phase are only executed once, therefore, if net total was
changed on the ORDERS form the new total would be carried over to the
TOTALS form by the FIELD statement.
When the TOTALS form is displayed, the total net price calculated on the
previous form (ORDER) is shown in the TOTNET field. Then, when the user
presses ENTER, the remaining values in the form are calculated, and all
values are written to the batch file. The calculated values do not
appear during data collection, but only when the batch file is browsed.
Figure 6-12. Main Menu, Compile Selection
Action
Compile the forms file to record the new specifications in
machine-readable form, as shown in Figure 6-12.
Table 6-4 and Table 6-5 summarize all the current field specifications
for the ORDER and TOTALS forms. (Refer to Table 6-1 for a summary of the
save field specifications.)
Table 6-4. Summary of Current Fields in ORDER
------------------------------------------------------------------------------------------------------
| | | | | |
| Field | | | | |
| | | | | |
------------------------------------------------------------------------------------------------------
| | | | | | |
| Num | Name | FType | DType | Processing | Initial Valu|
| | | | | Specifications | |
| | | | | | |
------------------------------------------------------------------------------------------------------
| | | | | | |
| 8 | ORDNUM | D | DIG | INIT | -- |
| | | | | SET ORDNUM TO SORDNUM | |
| | | | | | |
| 1 | ORDATE | D | MDY | INIT | -- |
| | | | | SET ORDATE TO $TODAY | |
| | | | | | |
| 2 | NAME | R | CHAR | SET SNAME TO NAME | -- |
| | | | | | |
| 3 | ADDRESS | O | CHAR | -- | -- |
| 4 | CITY | O | CHAR | -- | -- |
| | | | | | |
| 5 | ST | O | CHAR | IN $STATE | -- |
| | | | | | |
| 6 | ZIP | O | CHAR | MATCH ddddd[-dddd] | -- |
| | | | | | |
| 7 | PHONE | O | CHAR | MATCH [(ddd)]b*ddd-dddd | -- |
| 9 | QTY | R | DIG | GE 1 | -- |
| | | | | | |
| 10 | PARTNUM | R | CHAR | MATCH Puddd-??? | -- |
| 11 | DESCRIPTION | O | CHAR | -- | -- |
| | | | | | |
| 12 | UPRICE | R | NUM2 | JUSTIFY RIGHT | -- |
| | | | | STRIP LEADING "0" | |
| | | | | | |
| 13 | TPRICE | D | NUM2 | SET TPRICE TO QTY * UPRICE | -- |
| | | | | SET STOTNET TO TPRICE | |
| | | | | | |
------------------------------------------------------------------------------------------------------
Table 6-5. Summary of Current Fields in TOTALS
-------------------------------------------------------------------------------------------------------
| | | | | |
| Field | | | | |
| | | | | |
-------------------------------------------------------------------------------------------------------
| | | | | | |
| Num | Name | FType| DType | Processing | Value |
| | | | | Specifications | |
| | | | | | |
-------------------------------------------------------------------------------------------------------
| | | | | | |
| 1 | ORDNUM | D | DIG | INIT | -- |
| | | | | SET ORDNUM TO SORDNUM | |
| | | | | IF SORDNUM GT 999999 THEN | |
| | | | | SET SORDNUM TO 100001 | |
| | | | | ELSE SET SORDNUM TO | |
| | | | | SORDNUM + 1 | |
| | | | | | |
| 2 | ORDATE | D | MDY | INIT | -- |
| | | | | SET ORDATE TO $TODAY | |
| | | | | | |
| 3 | TOTNET | D | NUM2 | INIT | -- |
| | | | | SET TOTNET TO STOTNET | |
| | | | | FIELD | |
| | | | | SET TOTNET TO STOTNET | |
| | | | | | |
| 4 | DISCNT_PERCNT | O | NUM0 | -- | 10 |
| | | | | | |
| 5 | DISCNT | D | NUM2 | IF TOTNET GE 1000 THEN | -- |
| | | | | SET DISCNT TO DISCNT_PERCNT | |
| | | | | % TOTNET | |
| | | | | ELSE SET DISCNT TO 0 | |
| | | | | | |
| 6 | SUB | D | NUM2 | SET SUB TO TOTNET - DISCNT | -- |
| 7 | TAX_RATE | R | NUM2 | -- | 6.25 |
| 8 | TAX | D | NUM2 | SET TAX TO TAX_RATE % SUB | -- |
| 9 | SHIP | O | NUM2 | JUSTIFY RIGHT | .00 |
| | | | | STRIP LEADING "0" | |
| | | | | | |
| 10 | TOTAL | D | NUM2 | SET TOTAL TO SUB + TAX + | -- |
| | | | | SHIP | |
| | | | | | |
| 11 | NAME | D | CHAR | SET NAME TO SNAME | -- |
| | | | | | |
-------------------------------------------------------------------------------------------------------
___________________________________________________________________________
| |
| :RUN ENTRY.PUB.SYS |
| |
| HP32209v.uu.ff ENTRY (C) HEWLETT-PACKARD CO. 1986 |
| |
| ENTER FORMS FILE NAME AND PRESS RETURN: ORDFORM1 |
| ENTER BATCH FILE NAME AND PRESS RETURN: DATA6 |
___________________________________________________________________________
Figure 6-13. Run ENTRY and the Completed ORDER Form, Record No. 1
MPE/iX 5.0 Documentation