Setting Up a Menu-Driven System [ Getting Started With TRANSACT V ] MPE/iX 5.0 Documentation
Getting Started With TRANSACT V
Setting Up a Menu-Driven System
Now all we need to do is tie the pieces together with a menu and we have
a complete system for adding, updating, and reporting data. A mainmenu
form does the trick. The format of the form is:
_____________________________________________________
| |
| mainmenu Customer module |
| |
| |
| f1 = add customer |
| |
| f2 = update customer|
| |
| f3 = report customer|
| |
| F8 = exit |
| |
_____________________________________________________
Figure 3-19. VPLUS form for main menu
Now we can integrate the individual programs we wrote earlier into a
program driven by the main menu. Depending on the choice entered on the
mainmenu, the program will execute the code to add, update, or report a
customer.
The program might look like the one below.
_______________________________________________________________________
| |
| 1 system ex30,base=orders,vpls=formfile; |
| 2 list(auto) customer; |
| 3 level; |
| 4 get(form) mainmenu,f1=add-customer |
| ,f2=update-customer |
| ,f3=report-customer; |
| 5 end; |
| |
| 6 add-customer: |
| |
| 7 get(form) vcustomer; |
| 8 put customer; |
| 9 end; |
| |
| 10 update-customer: |
| |
| 11 get(form) vcustno; |
| 12 set(key) list (cust-no); |
| 13 get customer; |
| 14 put(form) vcustomer; |
| 15 get(form) vcustomer; |
| 16 update customer; |
| 17 end; |
| |
| 18 report-customer: |
| |
| 19 get(form) vcustno; |
| 20 set(key)list (cust-no); |
| 21 get customer; |
| 22 put(form) vcustomer,wait= |
| 23 ,window=("press f1-f7 to continue");|
| 24 set(form) vcustomer,window=(" "); |
| 25 end; |
_______________________________________________________________________
Figure 3-20. VPLUS menu-driven program
4 The GET statement drives the program. The mainmenu is displayed
and, depending on the function key entered, various routines are
executed. When any of the three tasks finishes, END returns
control to the first line in the present level, which is line 4.
The options F1=, F2=, and F3= specify a conditional transfer of
control depending on the function key pressed. This is like a
GOTO rather than a PERFORM. However, by proper use of the LEVEL
and END, the logic flow can be made to resemble a PERFORM more
closely.
5 END returns control to the start of the current level which means
we return to statement 4.
6 The code to add a customer executes when the user presses [[ F1
]].
9 END returns control to the start of the current level which means
we return to statement 4.
10 The code to update a customer executed when the user presses [[
F2 ]].
17 END returns control to the start of the current level which means
we return to statement 4.
18 The code to report a customer executes when the user presses [[
F3 ]].
25 END returns control to the start of the current level which means
we return to statement 4.
By default, if [[ F8 ]] is pressed, we terminate the program.
MPE/iX 5.0 Documentation