Example: orders.4gl (header)
The orders.4gl header declares the schema to be used, the types and module variables.
The orders.4gl module header:
1 IMPORT FGL comutils
2 IMPORT FGL custlist
3 IMPORT FGL stocklist
4
5 SCHEMA custdemo
6
7 PRIVATE TYPE t_order RECORD
8 cust_num LIKE orders.cust_num,
9 cust_name LIKE customer.cust_name,
10 order_num LIKE orders.order_num,
11 order_date LIKE orders.order_date,
12 fac_code LIKE orders.fac_code,
13 ship_instr LIKE orders.ship_instr,
14 promo LIKE orders.promo
15 END RECORD
16
17 PRIVATE TYPE t_item RECORD
18 stock_num LIKE items.stock_num,
19 description LIKE stock.description,
20 quantity LIKE items.quantity,
21 unit LIKE stock.unit,
22 price LIKE items.price,
23 line_total DECIMAL(9,2)
24 END RECORD
25
26 PRIVATE DEFINE order_rec t_order
27 PRIVATE DEFINE ordnums DYNAMIC ARRAY OF INTEGER
28 PRIVATE DEFINE orders_index INTEGER
29 PRIVATE DEFINE orditems DYNAMIC ARRAY OF t_item
30 PRIVATE DEFINE order_total DECIMAL(9,2)
31
32 CONSTANT title1 = "Orders"
33 CONSTANT title2 = "Items"
34
35 CONSTANT msg01 = "No orders found"
36 CONSTANT msg02 = "Enter search criteria"
37 CONSTANT msg03 = "Canceled by user"
38 CONSTANT msg04 = "No rows found, enter new search criteria"
39 CONSTANT msg05 = "End of list"
40 CONSTANT msg06 = "Beginning of list"
41 CONSTANT msg07 = "Invalid stock number"
42 CONSTANT msg08 = "Row added to the database"
43 CONSTANT msg09 = "Row updated in the database"
44 CONSTANT msg10 = "Row deleted from the database"
45 CONSTANT msg11 = "New order record created"
46 CONSTANT msg12 = "Order date is in the past"
47 CONSTANT msg13 = "Quantity must be greather than zero"
48 CONSTANT msg14 = "%1 orders found in the database"
49 CONSTANT msg15 = "There are no orders selected, exit program?"
50 CONSTANT msg16 = "Item is not available in current factory %1"
51 CONSTANT msg17 = "Order %1 saved in database"
52 CONSTANT msg18 = "Order input program, version 1.01"
53 CONSTANT msg19 = "Moving focus to another row or to order header saves changes"
54 CONSTANT msg20 = "Could not create new order, program stops"
55 CONSTANT msg21 = "Order %1/%2"
56
57 CONSTANT move_first = -2
58 CONSTANT move_prev = -1
59 CONSTANT move_next = 1
60 CONSTANT move_last = 2
Note:
- Line
1
thru3
declare the modules to be imported by this main module. - Line
5
defines the database schema to be used by this module. - Lines
7
thru15
define thet_order
type as aRECORD
with members declared with aLIKE
reference to the database column. This type will be used for theorders
records. - Lines
17
thru24
define thet_item
as aRECORD
to be used for theitems
records. - Line
26
defines theorder_rec
variable, to hold the data of the current order header. - Line
27
defines theordnums
dynamic array with thet_order
type, to hold the list of order numbers fetched from the last query. This array will be used to navigate in the current list of orders. - Line
28
defines theorders_index
variable, defining the current order in thearr_ordnums
array. - Line
29
defines theitems
dynamic array with thet_item
type, to hold the lines of the current order. - Line
30
defines theorder_total
variable with a decimal type, containing the order amount. - Lines
32
thru55
define string constants with text messages used by the orders.4gl module. This is a good practice, to simplify the internationalization of your applications. - Lines
57
thru60
define numeric constants used for theorder_move
navigation function.