Full list mode of DISPLAY ARRAY

In order to handle short/medium result sets, use the full list mode of DISPLAY ARRAY.

Understanding the full list mode

In full list mode, DISPLAY ARRAY uses a complete copy of the result set to be displayed in the form array. The full list mode is typically used for a short or medium row set (10 - 100 rows).

In full list mode, the DISPLAY ARRAY instruction uses a static or dynamic program array defined with a record structure corresponding to (or to a part of ) a screen-array in the current form.

The program array is filled with data rows before DISPLAY ARRAY is executed, typically with a FOREACH loop when rows come from the database.

Figure: Full list mode in DISPLAY ARRAY diagram


Full list mode diagram

Consider using a dynamic array instead of a static array: By using a dynamic array the program will only use the required memory resources, and the dialog will automatically detect the number of rows from the dynamic array (array.getLength())

Full list mode example

The following example implements a DISPLAY ARRAY in its simpler form: A dynamic array is filled with database rows and contains the whole result set to be displayed in the table:
MAIN
  DEFINE arr DYNAMIC ARRAY OF RECORD
            id INTEGER,
            fname CHAR(30),
            lname CHAR(30)
        END RECORD 
  DEFINE i INTEGER

  DATABASE stores

  OPEN FORM f1 FROM "custlist"
  DISPLAY FORM f1

  DECLARE c1 CURSOR FOR
         SELECT customer_num, fname, lname FROM customer 
  LET i=1
  FOREACH c1 INTO arr[i].*
      LET i = i+1
  END FOREACH
  CALL arr.deleteElement(i)

  DISPLAY ARRAY arr TO sa.* ATTRIBUTES(UNBUFFERED)
      BEFORE ROW
        MESSAGE "Moved to row ", arr_curr() 
  END DISPLAY

END MAIN