Main block and misc functions
This section provides details about the MAIN
module, the function
implementing the CONSTRUCT
instruction and the function fetching rows into the
program array.
Filling program arrays with rows A program array is an ordered set of elements all of the same data type.The elements of the array can be simple types or they can be records. The FOREACH
instruction can be used to fill program arrays with SQL rows.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.Example: custlist.4gl (MAIN block) The MAIN
block implements a WHILE
loop, to let the user first enter a query filter, then browse rows in the filtered result set, and repeat the same process until the Cancel button is selected. Example: custlist.4gl (Function custlist_query) The custlist_query function implements the CONSTRUCT
instruction to get an SQL condition that will be used in the SELECT
statement to filter customer table rows.Example: custlist.4gl (Function custarr_fill) The custarr_fill
function fetches rows from the customer SQL table, according to the SQL condition passed as parameter.