DISPLAY ARRAY programming steps
Follow this procedure to use the DISPLAY ARRAY
dialog
instruction.
To implement a DISPLAY ARRAY
statement:
- Create a form specification file containing a screen array. The screen array identifies the presentation elements to be used by the runtime system to display the rows.
- Make sure that the program controls interruption handling
with
DEFER INTERRUPT
, to manage the validation/cancellation of the interactive dialog. - Define an array of records with the
DEFINE
instruction. The members of the program array must correspond to the elements of the screen array, by number and data types. Static or a dynamic arrays can be used for the full list mode, but the paged mode requires a dynamic array. For new developments, use dynamic arrays in both cases. - Open and display the form, using
OPEN WINDOW WITH FORM
or theOPEN FORM
/DISPLAY FORM
instructions. - If you want to use the full list mode, fill the program array with data, typically with a result set cursor, counting the number of program records being filled with retrieved data.
-
Set the
INT_FLAG
variable toFALSE
. - Write the
DISPLAY ARRAY
statement block. When using a static array, specify the number of rows with theCOUNT
attribute in theATTRIBUTES
clause, or call theSET_COUNT()
function before the dialog block. With dynamic arrays, the number of rows is automatically known by the dialog. Consider using theUNBUFFERED
mode in new developments. - If you want to use the paged mode, define the total number
of rows with the
COUNT
attribute (can be -1 for infinite number of rows), and add theON FILL BUFFER
clause that will contain the code to fill the dynamic array with the expected rows fromfgl_dialog_getBufferStart()
tofgl_dialog_getBufferLength()
. - If multi-row selection is needed, call the
ui.Dialog.setSelectionMode()
method inBEFORE DISPLAY
to enable this mode. -
Inside the
DISPLAY ARRAY
block, control the behavior of the instruction withBEFORE ROW
,AFTER ROW
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
, reset it toFALSE
to not disturb code that relies on this variable to detect interruption events from the GUI front-end or TUI console. - If needed, get the current row with the
ARR_CURR()
built-in function after dialog execution. During dialog execution, you can also useDIALOG.getCurrentRow()
.