CONSTRUCT programming steps

The following steps describe how to implement the CONSTRUCT statement:

  1. Declare a variable with the DEFINE statement, it can be CHAR, VARCHAR or STRING. Prefer STRING to avoid any size limitation.
  2. Open and display the form, using an OPEN WINDOW WITH FORM or the OPEN FORM / DISPLAY FORM instructions.
  3. Set the INT_FLAG variable to FALSE.
  4. 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.
  5. Inside the CONSTRUCT statement, control the behavior of the instruction with BEFORE CONSTRUCT, BEFORE FIELD, AFTER FIELD, AFTER CONSTRUCT and ON ACTION blocks.
  6. 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 the INT_FLAG variable is TRUE, you should reset it to FALSE to not disturb code that relies on this variable to detect interruption events from the GUI front-end or TUI console.
  7. To build the complete SQL statement, concatenate "SELECT ... WHERE" to the string variable that contains the boolean SQL expression produced by CONSTRUCT.
  8. Define a database cursor with the DECLARE FROM instruction, by using the SELECT statement.
  9. 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 a DISPLAY ARRAY statement.