TOPIC: CHANGE FORM SEQUENCE PROGRAMMATICALLY [ 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
TOPIC: CHANGE FORM SEQUENCE PROGRAMMATICALLY
The basic control of forms sequence is established on the Form Menu. For
example, the repeating form ORDER_LINE is defined on its Form Menu as a
repeating appended form by the A in the Repeat Option selection box; and
the frozen first form ORDER_HEAD is so defined by an F in the Next Form
selection box. A CHANGE statement is provided by FORMSPEC that allows
you to change these specifications during execution of the forms file.
CHANGE Statement
The CHANGE statement allows you to change form specifications as follows:
The current form can be changed to: NOREPEAT
REPEAT
REPEAT APPEND
The next form option can be changed to: CLEAR
APPEND
FREEZE APPEND
and the next form name can be changed to: "form name"
field name (field contains a form name)
index retrieve (select from form names)
$RETURN
$HEAD
$END
$REFRESH
Usually, the CHANGE statement is used in conjunction with an IF statement
so that the form option or next form name is changed only under specified
circumstances.
At this point in the exercise, there is no limit to the number of times
the repeating form ORDER_LINE is issued. If the form is appended so many
times that it fills the screen, the first ORDER_LINE is rolled off the
screen, leaving ORDER_HEAD frozen on the screen above the second
ORDER_LINE. This continues until the user presses NEXT FORM in ENTRY to
stop the repeat and display the next different form.
Now let's use the CHANGE statement to stop the repeat automatically when
the screen is full. In other words, in the exercise, you will use the
CHANGE statement to change the current form to NOREPEAT after it has been
repeated a specified number of times. This forces the repeat to
terminate and the next different form to be displayed even if the user
does not press NEXT FORM in ENTRY. As another example, you will also use
the CHANGE statement to terminate the display of forms before the order
number reaches the value 1,000,000. (As presently defined, the order
number is reset to 100,001 when it reaches 999,999.)
Action
For a full discussion of the CHANGE statement, refer to Section 4 of the
VPLUS/V Reference Manual.
Figure 7-16. The LINE_COUNT Save Field
The first step is to change the repeat option of ORDER_LINE so that it is
terminated automatically when ORDER_LINE has been repeated seven times.
(ORDER_LINE can be repeated seven times before the screen is full.) You
need to use a save field as the counter to determine the number of times
ORDER_LINE is repeated; this save field is initialized by a field in
ORDER_HEAD, and incremented in the initialization phase of a field in
ORDER_LINE.
Action
Press MAIN/RESUME to display the Main Menu; use option S--add a save
field; press ENTER.
On the Save Field Menu, name the save field LINE_COUNT and specify that
it is data type of DIG with a length of two digits as shown in Figure
7-16. Press ENTER.
Figure 7-17. The Field Menu for QTY
Since QTY is the first field in ORDER_LINE, you use that field to
increment the LINE_COUNT save field and conditionally terminate the
repeat.
Action
Return to the Main Menu and use option G--to go to the QTY field of
ORDER_LINE, where you specify the statements to increment the LINE_COUNT
save field, as shown in Figure 7-17.
Note that the existing edit statement must be preceded by a FIELD heading
so that it is not executed in the initialization phase. Since the other
statements are executed in the initialization phase, they are performed
before the form is displayed on the screen. Now you need to give
LINE_COUNT an initial value because it must be initialized each time a
new order transaction is started.
Action
Return to the Main Menu and use option G--to go to the ORDNUM field of
ORDER_HEAD, where you specify the statements: INIT and SET LINE_COUNT TO
0.
These statements initialize the LINE_COUNT save field to zero. The
counter can be incremented in any field in ORDER_LINE, but it must be
incremented in the initialization phase so that the count is not affected
by modifications made in Browse mode.
Figure 7-18. The Field Menu for ORDNUM
The next example of using a CHANGE statement affects the Next Form
option. The current specification for the ORDNUM field has a length of
six digits. Thus, if the order number is incremented above the value
999999, it no longer fits in the field. As currently defined, the order
number is reset to 100001 before it overflows the field. Another
solution is to terminate execution of the forms file when the order
number gets too big.
Action
Change the Field Menu of ORDNUM in the ORDER_TOTALS form as shown in
Figure 7-18. Press ENTER.
This completes the specifications for the form ORDFORM1. Table 7-1
summarizes the global specifications for ORDFORM1, including the four
save fields; Table 7-2, Table 7-3 and Table 7-4 summarizes the field
specifications for all the forms in the file.
Action
Return to the Main Menu and compile the form so that it can be used for
data entry. Press EXIT.
Table 7-1. Summary of Globals and Save Fields in ORDFORM1
Table 7-2. Summary of ORDFORM1 Fields
Table 7-3. Summary of ORDFORM1 Fields (cont'd)
Table 7-4. Summary of ORDFORM1 Fields (cont'd)
___________________________________________________________________________
| |
| :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: DATA7 |
___________________________________________________________________________
Figure 7-19. The ORDER_HEAD Form as Initially Displayed
MPE/iX 5.0 Documentation