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 RECORDNote:
- Line
1declares the database schema to find column types forLIKEclauses. - Line
3defines thet_custrectype as a record by using the list of column names and column types of thecustomertable. - Line
4defines the typet_custarras a dynamic array of records of typet_custrec. - Line
5defines a dynamic array, from the thet_custarrtype. - Line
7thru10define 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).