Example: custmain.4gl
This module contains the MAIN program block for the query program,
and the MENU that drives the query actions.
Module custmain.4gl:
1 IMPORT FGL custquery
2
3 MAIN
4
5 DEFER INTERRUPT
6
7 CONNECT TO "custdemo"
8
9 CLOSE WINDOW SCREEN
10 OPEN WINDOW w1 WITH FORM "custform"
11 ATTRIBUTES(TEXT="Customer")
12
13 MENU "Customer"
14 ON ACTION query ATTRIBUTES(COMMENT="Search for customers")
15 CALL custquery.query_cust()
16 ON ACTION next
17 CALL custquery.fetch_rel_cust(1)
18 ON ACTION previous
19 CALL custquery.fetch_rel_cust(-1)
20 ON ACTION quit
21 EXIT MENU
22 END MENU
23
24 CLOSE WINDOW w1
25
26 DISCONNECT CURRENT
27
28 END MAINNote:
- Line
1: Declare that thecustquerymodule must be imported, by using theIMPORT FGLinstruction. This is mandatory in order to use symbols such as functions, that are defined in the custquery module. - Note that the
SCHEMAstatement is not needed since this module does not define any program variables in terms of a database table. - Line
3: Beginning of theMAINblock. - Line
5uses theDEFER INTERRUPTstatement to prevent the user from terminating the program prematurely with a SIGINT for example. - Line
10opens a window with the form file. - Lines
13thru22contains theMENUfor the query program. Four actions -query,next,previous, andquit- will be displayed as buttons on the form. - Line
15calls the functionquery_custin the cust_query module. - Line
17calls the functionfetch_rel_custin the cust_query module. The literal value 1 is passed to the function, indicating that the cursor should move forward to the next row. - Line
19calls the functionfetch_rel_custalso, but passes the literal value -1, indicating that the cursor should move backwards to retrieve the previous row in the results set.
There are no further statements so the Query program terminates after leaving the
MENU dialog.