Example: custlist.4gl types and variables

The custlist.4gl module defines a couple of types and a module variable to hold the customer records in memory.

In this demo, we will use a dynamic array to hold customer records. For maximum reusability, we define types with the TYPE instruction.

Top of the custlist.4gl source:
  1 SCHEMA custdemo
  2 
  3 TYPE t_custrec RECORD LIKE customer.*
  4 TYPE t_custarr DYNAMIC ARRAY OF t_custrec
  5 DEFINE custarr t_custarr
  6 
  7 DEFINE custatt DYNAMIC ARRAY OF RECORD
  8          cust_num STRING,
  9          cust_name STRING
 10      END RECORD
Note:
  • Line 1 declares the database schema to find column types for LIKE clauses.
  • Line 3 defines the t_custrec type as a record by using the list of column names and column types of the customer table.
  • Line 4 defines the type t_custarr as a dynamic array of records of type t_custrec.
  • Line 5 defines a dynamic array, from the the t_custarr type.
  • Line 7 thru 10 define another dynamic array of record, with only two members, to hold the cell decoration attributes. We will discuss this later in Example custlist.4gl (Function custarr_display).