| Tutorial Chapter 6: Add, Update and Delete / Adding a new row | |
The MENU statement in the module custmain.4gl is modified to call functions for adding, updating, and deleting the rows in the customer table.
01 -- custmain.4gl
02
03 MAIN
04 DEFINE query_ok INTEGER
05
06 DEFER INTERRUPT
07 CONNECT TO "custdemo"
08 SET LOCK MODE TO WAIT 6
09 CLOSE WINDOW SCREEN
10 OPEN WINDOW w1 WITH FORM "custform"
11
12 MENU
13 ON ACTION find
14 LET query_ok = query_cust()
15 ON ACTION next
16 IF query_ok THEN
17 CALL fetch_rel_cust(1)
18 ELSE
19 MESSAGE"You must query first."
20 END IF
21 ON ACTION previous
22 IF query_ok THEN
23 CALL fetch_rel_cust(-1)
24 ELSE
25 MESSAGE "You must query first."
26 END IF
27 COMMAND "Add"
28 IF inpupd_cust("A") THEN
29 CALL insert_cust()
30 END IF
31 COMMAND "Delete"
32 IF delete_check() THEN
33 CALL delete_cust()
34 END IF
35 COMMAND "Modify"
36 IF inpupd_cust("U") THEN
37 CALL update_cust()
38 END IF
39 ON ACTION quit
40 EXIT MENU
41 END MENU
42
43 CLOSE WINDOW w1
44
45 DISCONNECT CURRENT
46
47 END MAIN