Tutorial Chapter 11: Master/Detail / The Orders Program orders.4gl |
The MAIN program block contains the menu for the orders program.
01 SCHEMA custdemo 02 03 DEFINE order_rec RECORD 04 store_num LIKE orders.store_num, 05 store_name LIKE customer.store_name, 06 order_num LIKE orders.order_num, 07 order_date LIKE orders.order_date, 08 fac_code LIKE orders.fac_code, 09 ship_instr LIKE orders.ship_instr, 10 promo LIKE orders.promo 11 END RECORD, 12 arr_items DYNAMIC ARRAY OF RECORD 13 stock_num LIKE items.stock_num, 14 description LIKE stock.description, 15 quantity LIKE items.quantity, 16 unit LIKE stock.unit, 17 price LIKE items.price, 18 line_total DECIMAL(9,2) 19 END RECORD 20 21 CONSTANT msg01 = "You must query first" 22 CONSTANT msg02 = "Enter search criteria" 23 CONSTANT msg03 = "Canceled by user" 24 CONSTANT msg04 = "No rows in table" 25 CONSTANT msg05 = "End of list" 26 CONSTANT msg06 = "Beginning of list" 27 CONSTANT msg07 = "Invalid stock number" 28 CONSTANT msg08 = "Row added" 29 CONSTANT msg09 = "Row updated" 30 CONSTANT msg10 = "Row deleted" 31 CONSTANT msg11 = "Enter order" 32 CONSTANT msg12 = "This customer does not exist" 33 CONSTANT msg13 = "Quantity must be greater than zero" 34 35 MAIN 36 DEFINE has_order, query_ok SMALLINT 37 DEFER INTERRUPT 38 39 CONNECT TO "custdemo" 40 CLOSE WINDOW SCREEN 41 42 OPEN WINDOW w1 WITH FORM "orderform" 43 44 MENU 45 BEFORE MENU 46 CALL setup_actions(DIALOG,FALSE,FALSE) 47 ON ACTION new 48 CLEAR FORM 49 LET query_ok = FALSE 50 CALL close_order() 51 LET has_order = order_new() 52 IF has_order THEN 53 CALL arr_items.clear() 54 CALL items_inpupd() 55 END IF 56 CALL setup_actions(DIALOG,has_order,query_ok) 57 ON ACTION find 58 CLEAR FORM 59 LET query_ok = order_query() 60 LET has_order = query_ok 61 CALL setup_actions(DIALOG,has_order,query_ok) 62 ON ACTION next 63 CALL order_fetch_rel(1) 64 ON ACTION previous 65 CALL order_fetch_rel(-1) 66 ON ACTION getitems 67 CALL items_inpupd() 68 ON ACTION quit 69 EXIT MENU 70 END MENU 71 72 CLOSE WINDOW w1 73 74 END MAIN