Module custmain.4gl
The MENU
statement in the module
custmain.4gl is modified to call functions
for adding, updating, and deleting the rows in the customer
table.
The
MAIN
block
(custmain.4gl)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
Note:
- Line
08
sets the lock timeout period to 6 seconds. - Lines
12
thru41
define the main menu of the program. - Lines
27
thru30
TheMENU
option Add now calls aninpupd_cust
function. Since this same function will also be used for updates, the value "A", indicating an Add of a new row, is passed. Ifinpupd_cust
returnsTRUE
, theinsert_cust
function is called. - Lines
31
thru34
TheMENU
option Delete now calls adelete_check
function. Ifdelete_check
returnsTRUE
, thedelete_cust
function is called. - Lines
35
thru38
are added to theMENU
statement for the Modify option, calling theinpud_cust
function. The value "U", for an Update of a new row, is passed as a parameter. Ifinpupd_cust
returnsTRUE
, theupdate_cust
function is called.