Getting Started with TRANSACT (32247-90007)

62 Chapter3
Using VPLUS and IMAGE
Adding Data to a Dataset
Figure 3-4. Using Command Mode with VPLUS for Looping
Another way to get the program to loop is to build the repeating structure into the
program, using either a LEVEL or a REPEAT statement. The following programs show
these two possibilities.
Figure 3-5. Using LEVEL with VPLUS for Looping
Lines 3-5 of the above program execute until the user presses [[ F8 ]].
Figure 3-6. Using REPEAT with VPLUS for Looping
The user can terminate this program either by pressing [[ENTER]] without entering any
data or by pressing [[ F8 ]]. However, [[ENTER]] causes Transact to create a blank record
with a zero customer number.
Since we probably do not want such a record in the dataset, we should change the above
program as shown in Figure 3-7 to make it more practical.
1 system ex21,base=orders,vpls=formfile;
2 $$add:
3 list(auto) customer;
4 get(form) vcustomer,init;
5 put customer
1 system ex22,base=orders,vpls=formfile;
2 level;
3 list(auto) customer;
4 get(form) vcustomer,init;
5 put customer;
1 system ex23,base=orders,vpls=formfile;
2 list(auto) customer;
3 repeat
4 do
5 get(form) vcustomer,init;
6 put customer;
7 doend
8 until (cust-no) = 0;
9 exit;