CONSTRUCT programming steps
Follow this procedure to use the CONSTRUCT
dialog
instruction.
To implement a CONSTRUCT
statement:
-
Declare a variable with the
DEFINE
statement, it can beCHAR
,VARCHAR
orSTRING
.STRING
is preferred in order to avoid any size limitation. -
Open and display the form, using an
OPEN WINDOW WITH FORM
or anOPEN FORM
/DISPLAY FORM
instruction. -
Set the
int_flag
variable toFALSE
. -
Define the
CONSTRUCT
block with the list of form fields to be used for the query by example. If needed, define dialog control blocks to implement rules for the query by example. -
Inside the
CONSTRUCT
statement, control the behavior of the instruction withBEFORE CONSTRUCT
,BEFORE FIELD
,AFTER FIELD
,AFTER CONSTRUCT
andON ACTION
blocks. -
After the interaction statement block, test the
int_flag
predefined variable to check if the dialog was canceled (int_flag=TRUE
) or validated (int_flag=FALSE
).If theint_flag
variable isTRUE
, you should reset it toFALSE
to not disturb code that relies on this variable to detect interruption events from the GUI front-end or TUI console. - To build the complete SQL statement, concatenate "
SELECT ... WHERE
" to the string variable that contains the boolean SQL expression produced byCONSTRUCT
. -
Define a database cursor with the
DECLARE FROM
instruction, by using theSELECT
statement. -
Execute the cursor and fetch the rows found by the database server. You can for example
implement a
FOREACH
loop to fill a program array, to be shown by aDISPLAY ARRAY
statement.