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
DEFINEinstruction. 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 an
OPEN WINDOW WITH FORMor theOPEN FORM/DISPLAY FORMinstructions. - 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_flagvariable toFALSE. -
Write the
INPUT ARRAYdialog block to handle data input. Set theWITHOUT DEFAULTSoption appropriately. -
Inside the
INPUT ARRAYdialog, 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 INPUTandON ACTIONblocks. - Get the new number of rows with the
ARR_COUNT()built-in function or withDIALOG.getArrayLength(). - After the interaction statement block, test the
int_flagpredefined variable to check if the dialog was canceled (int_flag=TRUE) or validated (int_flag=FALSE). If theint_flagvariable isTRUE, it is recommended that you reset it toFALSEto not disturb code that relies on this variable to detect interruption events from the GUI front-end or TUI console.