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 aSTRING
variable,where_clause
, to hold theWHERE
clause created from the criteria entered in the form fields by the user. - Line
03
defines an integer variable,id
, to hold the store number selected by the user after triggering thedisplay_custlist
function of the custlist.4gl module. - Line
05
displays a message instructing the user to enter search criteria. - Lines
08
thru43
contain theWHILE
statement that is executed until an order is successfully selected or the user cancels the operation. - Lines
10
thru15
specify the form fields that will contain the search criteria for theCONSTRUCT
statement. - Lines
11
thru22
define anON ACTION
clause for thezoom1
button in theorderform
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 oforderform
. - Lines
24
thru25
display the message when the user selects theabout
menu item on theorderform
form. - Lines
29
thru42
test whether the user wants to interrupt the dialog and responds accordingly. - Lines
31
thru37
When the user interrupts, a message box is displayed if thearr_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
thru42
when the user has not interrupted, theorder_select
function is called to retrieve the order information; then theWHILE
loop is exited.