Getting Started with TRANSACT (32247-90007)
50 Chapter2
Using Character Mode I/O
Looping Structures
Looping Structures
In most of the examples, we have used LEVEL as the way to get a program to loop.
Transact also has the verbs REPEAT, UNTIL, and WHILE to control looping.
For example, we could have written the last program using REPEAT as follows:
Figure 2-16. Program Using REPEAT to Loop
7 The DO verb designates the start of a block of code that is to be executed
under the control of the current verb, in this case the REPEAT verb. The
block of code is terminated with a DOEND verb. This is line 16 in the
example. Thus lines 8 through 15 are executed under the control of the
REPEAT statement.
DO/DOEND can also be used with the WHILE and IF verbs.
Replacing REPEAT with WHILE, the program looks like: WHILE statement”
1 system ex16,base=orders(";");
2 list(auto) customer;
3 data cust-no ("enter cust-no to delete");
4 if (cust-no) <> 0
5 then
6 repeat
7 do
8 set(key) list (cust-no);
9 get customer;
10 display;
11 input "delete this customer?";
12 if input = "Y","YES"
13 then delete(current) customer
14 else display "customer not deleted";
15 data cust-no ("enter cust-no to delete");
16 doend
17 until (cust-no) = 0;