Example 2: Defining a type an using it in another module

The following example defines a type in first module, and then uses the type in a report program:

type_order.4gl:
PUBLIC TYPE rpt_order RECORD
                 order_num INTEGER,
                 store_num INTEGER,
                 order_date DATE,
                 cust_num INTEGER,
                 fac_code CHAR(3)
             END RECORD
report.4gl:
IMPORT FGL type_order

MAIN
  DEFINE o type_order.rpt_order

  CONNECT TO "custdemo"

  DECLARE order_c CURSOR FOR
     SELECT orders.*
        FROM orders ORDER BY cust_num
  START REPORT order_list
  FOREACH order_c INTO o.*
    OUTPUT TO REPORT order_list(o.*)
  END FOREACH
  FINISH REPORT order_list 

END MAIN 

REPORT order_list(ro)
  DEFINE ro rpt_order 
  FORMAT
    ON EVERY ROW
     PRINT ro.order_num, ...
  ...