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 02 defines a STRING variable, where_clause, to hold the WHERE clause created from the criteria entered in the form fields by the user.
  • Line03 defines an integer variable, id, to hold the store number selected by the user after triggering the display_custlist function of the custlist.4gl module.
  • Line 05 displays a message instructing the user to enter search criteria.
  • Lines 08 thru 43 contain the WHILE statement that is executed until an order is successfully selected or the user cancels the operation.
  • Lines 10 thru 15 specify the form fields that will contain the search criteria for the CONSTRUCT statement.
  • Lines 11 thru 22 define an ON ACTION clause for the zoom1 button in the orderform form 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 of orderform.
  • Lines 24 thru25 display the message when the user selects the about menu item on the orderform form.
  • Lines 29 thru 42 test whether the user wants to interrupt the dialog and responds accordingly.
  • Lines 31 thru 37 When the user interrupts, a message box is displayed if the arr_ordnums array is empty, allowing the user to exit the program, or to continue. If the array is not empty, the function simply returns.
  • Lines 39 thru 42 when the user has not interrupted, the order_select function is called to retrieve the order information; then the WHILE loop is exited.