The cust_report function

This new function contains the report driver, together with the logic to determine whether the user has attempted to interrupt the report.

Function cust_report (custreport2.4gl):
21 FUNCTION cust_report()
22
23 DEFINE pr_custrec RECORD
24       store_num   LIKE customer.store_num,
25       store_name  LIKE customer.store_name,
26       addr        LIKE customer.addr,
27       addr2       LIKE customer.addr2,
28       city        LIKE customer.city,
29       state       LIKE customer.state,
30       zip_code     LIKE customer.zip_code 
31       END RECORD,
32       rec_count, rec_total, 
33       pbar, break_num INTEGER
34
35   LET rec_count = 0     
36   LET rec_total = 0
37   LET pbar = 0
38   LET break_num = 0
39   LET INT_FLAG = FALSE
40
41   SELECT COUNT(*) INTO rec_total FROM customer 
42
43  LET break_num = (rec_total/10)  
44
45   DECLARE custlist CURSOR FOR
46     SELECT store_num, 
47        store_name, 
48        addr, 
49        addr2, 
50        city, 
51        state, 
52        zip_code 53     FROM CUSTOMER    
54      ORDER BY state, city 
55
56   START REPORT cust_list TO FILE "customers.txt"
57   FOREACH custlist INTO pr_custrec.*
58     OUTPUT TO REPORT cust_list(lr_custrec.*)
59     LET rec_count = rec_count+1
60    IF (rec_count MOD break_num)= 0 THEN 
61       LET pbar = pbar+1
62       DISPLAY pbar TO rptbar 
63       CALL ui.Interface.refresh() 
64      IF (INT_FLAG) THEN
65        EXIT FOREACH
66       END IF
67     END IF
68   END FOREACH
69
70   IF (INT_FLAG) THEN
71    LET INT_FLAG = FALSE
72    MESSAGE "Report cancelled"
73  ELSE
74     FINISH REPORT cust_list 
75     MESSAGE "Report finished"  
76  END IF
77
78 END FUNCTION
Note: