INPUT ARRAY programming steps
Follow this procedure to use the INPUT ARRAY
dialog
instruction.
To implement an INPUT 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. If you want to input data from a reduced set of columns, you must define a second screen array, containing the limited list of form fields, in the form file. You can then use the second screen array in anINPUT ARRAY a FROM sa.*
instruction. - Open and display the form, using a
OPEN WINDOW WITH FORM
or theOPEN FORM
/DISPLAY FORM
instructions. - If needed, fill the program array with data, for example with a result set cursor, counting the number of program records being filled with retrieved data.
- Set the
INT_FLAG
variable toFALSE
. - Write the
INPUT ARRAY
statement to handle data input. - Inside the
INPUT ARRAY
statement, control the behavior of the instruction with control blocks such asBEFORE INPUT
,BEFORE INSERT
,BEFORE DELETE
,BEFORE ROW
,BEFORE FIELD
,AFTER INSERT
,AFTER DELETE
,AFTER FIELD
,AFTER ROW
,AFTER INPUT
andON ACTION
blocks. - Get the new number of rows with the
ARR_COUNT()
built-in function or withDIALOG.getArrayLength()
. - 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
, it is recommended that you reset it toFALSE
to not disturb code that relies on this variable to detect interruption events from the GUI front-end or TUI console.