Function order_query
This function allows the user to search for a specific order by entering criteria
        into the form (Query by Example). This CONSTRUCT statement is not a
        sub-dialog of a DIALOG statement. It is a stand-alone statement called by
        the action find, triggered when the user selects the corresponding menu
        item or toolbar icon on the form orderform.
Function 
order_query
            (orders.4gl):01 FUNCTION order_query()
02   DEFINE where_clause STRING,
03         id INTEGER, name STRING
04
05   MESSAGE msg02
06   CLEAR FORM
07
08   WHILE TRUE
09     LET int_flag = FALSE
10     CONSTRUCT BY NAME where_clause ON
11       orders.store_num,
12       customer.store_name,
13       orders.order_num,
14       orders.order_date,
15       orders.fac_code 
16
17       ON ACTION zoom1
18         CALL display_custlist() RETURNING id, name 
19         IF id > 0 THEN
20           DISPLAY id TO orders.store_num 
21           DISPLAY name TO customer.store_name 
22         END IF
23
24       ON ACTION about 
25         CALL __mbox_ok(title1,msg18,"information")
26
27     END CONSTRUCT
28
29     IF int_flag THEN
30       MESSAGE msg03
31       IF arr_ordnums.getLength()==0 THEN
32         IF __mbox_yn(title1,msg15,"stop") THEN
33           EXIT PROGRAM
34         END IF
35         CONTINUE WHILE
36       END IF
37       RETURN
38     ELSE
39       IF order_select(where_clause) THEN
40         EXIT WHILE
41       END IF
42     END IF
43   END WHILE
44
45 END FUNCTION
Note: 
- Line 
02defines aSTRINGvariable,where_clause, to hold theWHEREclause created from the criteria entered in the form fields by the user. - Line
03defines an integer variable,id, to hold the store number selected by the user after triggering thedisplay_custlistfunction of the custlist.4gl module. - Line 
05displays a message instructing the user to enter search criteria. - Lines 
08thru43contain theWHILEstatement that is executed until an order is successfully selected or the user cancels the operation. - Lines 
10thru15specify the form fields that will contain the search criteria for theCONSTRUCTstatement. - Lines 
11thru22define anON ACTIONclause for thezoom1button in theorderformform specification file. After the user selects the desired customer from the customer list that is displayed, the customer number and name are stored in the corresponding fields oforderform. - Lines 
24thru25display the message when the user selects theaboutmenu item on theorderformform. - Lines 
29thru42test whether the user wants to interrupt the dialog and responds accordingly. - Lines 
31thru37When the user interrupts, a message box is displayed if thearr_ordnumsarray is empty, allowing the user to exit the program, or to continue. If the array is not empty, the function simply returns. - Lines 
39thru42when the user has not interrupted, theorder_selectfunction is called to retrieve the order information; then theWHILEloop is exited.