USE THE SAVE FIELDS [ 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
USE THE SAVE FIELDS
Now that you have defined the save fields, you need to modify the field
definition for the fields that transfer data to, or receive data from,
the newly defined save fields. In this exercise, you use the save fields
in conjunction with three fields on the ORDER form and three on the
TOTALS form. Let's consider the order number first. Not only do you
specify that the order number on the ORDER form is to be transferred to
the TOTALS form, but you specify that it is to be incremented
automatically by 1 until it reaches 999999, after which the order number
is reset to 100001.
The SORDNUM save field was given the initial value 100001. This is the
first sequential order number. Because the save field contains an
initial value, the initial value previously specified for the ORDNUM
field is not needed. Instead, you use the SET TO statement to transfer
the value in the SORDNUM save field to the ORDNUM field.
Action
To modify the ORDNUM field, request the Main Menu and enter the
specification shown in Figure Figure 6-4. When you press ENTER, the
Field Menu for ORDNUM is displayed.
Figure 6-5. The Field Menu for ORDNUM in the ORDER Form
Action
On this menu, first change the field type (FType) to D for display-only
and the data type (DType) to DIG as shown in Figure 6-5.
The DIG data type allows calculations to be performed on this field.
(This is done for consistency--the order number calculations are
performed on the SORDNUM save field rather than on the ORDNUM field in
either the ORDER form or the TOTALS form.
Action
Delete the initial value since it is no longer needed. Now, press FIELD
TOGGLE to go to the Processing Specifications area of the menu and enter
the statement shown in Figure 6-5. Press ENTER to record this field
definition.
Figure 6-6. Field Menu for ORDNUM in the TOTALS Form
Action
Now, go to the Field Menu for ORDNUM in the TOTALS form. As you did with
the similar field in the ORDER form, change the field type to D, the data
type to DIG, and delete the initial value. Then, go to the Processing
Specifications area of the menu and add the statements shown in Figure
6-6. Press ENTER.
The first time the ORDER form is displayed by ENTRY, the value of SORDNUM
is its initial value 100001. Since no change is made to the SORDNUM save
field between execution of the first form (ORDER) and the second form
(TOTALS), both forms for a single order have the same order number,
initially 100001.
The next time the ORDER form is displayed, it is for a new order. As a
result of the calculations in the ORDNUM field of the form TOTALS, this
number is 1 greater than the previous order number; that is it is 100002.
This continues until the order number is incremented to its maximum value
of 999999.
Note that the value of SORDNUM is tested before it is incremented. This
is done because the two ORDNUM fields and the SORDNUM save field are each
six digits long. A value greater than 999999 causes an overflow error
because it won't fit in these fields. To prevent such an error, the
order number is reset to its initial value when it reaches the maximum
amount the field can hold.
In order to insure that the order number is incremented only in Collect
mode, you need a way to prevent it from being incremented in Browse mode
whenever ENTER is pressed to correct data in TOTALS. Also, it would be
nice if the order numbers could be displayed when each form is initially
displayed on the screen. So far, you have had to go into Browse mode to
see the current order number. Fortunately, both these problems can be
solved by using phases.
MPE/iX 5.0 Documentation