114 lines
3.4 KiB
Plaintext
114 lines
3.4 KiB
Plaintext
# Property of Four Js*
|
|
# (c) Copyright Four Js 1995, 2019. All Rights Reserved.
|
|
# * Trademark of Four Js Development Tools Europe Ltd
|
|
# in the United States and elsewhere
|
|
#
|
|
# Four Js and its suppliers do not warrant or guarantee that these
|
|
# samples are accurate and suitable for your purposes. Their inclusion is
|
|
# purely for information purposes only.
|
|
|
|
IMPORT FGL Styles
|
|
IMPORT FGL CityList
|
|
|
|
DEFINE custarr DYNAMIC ARRAY OF RECORD
|
|
c_id INTEGER,
|
|
c_name VARCHAR(50),
|
|
c_ts DATETIME YEAR TO SECOND
|
|
END RECORD
|
|
|
|
DEFINE custcrit RECORD
|
|
cust_id STRING,
|
|
cust_name STRING,
|
|
cust_state STRING,
|
|
cust_city STRING,
|
|
cust_zipcode STRING
|
|
END RECORD
|
|
|
|
MAIN
|
|
DEFINE s INTEGER
|
|
DEFINE where_clause, name, state STRING
|
|
DEFINE first_rows SMALLINT
|
|
DEFINE first_rows_count INTEGER
|
|
|
|
OPTIONS INPUT WRAP
|
|
|
|
OPEN FORM f1 FROM "QueryCustomers"
|
|
DISPLAY FORM f1
|
|
|
|
CALL addCommonStyles()
|
|
CALL addStyleList1()
|
|
|
|
DIALOG ATTRIBUTES(FIELD ORDER FORM, UNBUFFERED)
|
|
|
|
INPUT BY NAME first_rows, first_rows_count
|
|
ON CHANGE first_rows
|
|
CALL DIALOG.setFieldActive("first_rows_count",first_rows)
|
|
END INPUT
|
|
|
|
CONSTRUCT BY NAME where_clause
|
|
ON cust_id,
|
|
cust_name,
|
|
cust_state,
|
|
cust_city,
|
|
cust_zipcode
|
|
AFTER FIELD cust_id,
|
|
cust_name,
|
|
cust_state,
|
|
cust_city,
|
|
cust_zipcode
|
|
DISPLAY BY NAME where_clause
|
|
END CONSTRUCT
|
|
|
|
DISPLAY ARRAY custarr TO sr.*
|
|
BEFORE ROW
|
|
MESSAGE SFMT("Row: %1/%2", DIALOG.getCurrentRow("sr"), DIALOG.getArrayLength("sr"))
|
|
END DISPLAY
|
|
|
|
BEFORE DIALOG
|
|
LET first_rows = FALSE
|
|
CALL DIALOG.setFieldActive("first_rows_count",FALSE)
|
|
|
|
ON ACTION zoom_city
|
|
CALL select_city(DIALOG.getFieldBuffer("cust_city")) RETURNING s, name, state
|
|
IF s==0 THEN
|
|
DISPLAY name, state TO cust_city, cust_state
|
|
END IF
|
|
|
|
-- Save/Load criterias: would be nice to have DIALOG.setFieldBuffer
|
|
-- to make it generic.
|
|
ON ACTION clear_criterias
|
|
CLEAR cust_id, cust_name, cust_state, cust_city, cust_zipcode
|
|
LET where_clause = NULL
|
|
DISPLAY BY NAME where_clause
|
|
ON ACTION load_criterias
|
|
DISPLAY BY NAME custcrit.*
|
|
ON ACTION save_criterias
|
|
CALL get_fldbuf( cust_id, cust_name, cust_state, cust_city, cust_zipcode )
|
|
RETURNING custcrit.*
|
|
|
|
ON ACTION fetch
|
|
DISPLAY BY NAME where_clause
|
|
CALL cust_loadlist(300 / LENGTH(where_clause))
|
|
|
|
ON ACTION clear_list
|
|
CALL cust_loadlist(0)
|
|
|
|
ON ACTION close
|
|
EXIT DIALOG
|
|
|
|
END DIALOG
|
|
|
|
END MAIN
|
|
|
|
-- Dummy function to fill the list of customers (normally, SELECT from database)
|
|
FUNCTION cust_loadlist(m)
|
|
DEFINE m,i INTEGER
|
|
CALL custarr.clear()
|
|
FOR i=1 TO m
|
|
CALL custarr.appendElement()
|
|
LET custarr[i].c_id = i
|
|
LET custarr[i].c_name = "Name " || i
|
|
LET custarr[i].c_ts = CURRENT
|
|
END FOR
|
|
END FUNCTION
|