The INPUT ARRAY sub-dialog

The INPUT ARRAY sub-dialog is the controller to implement the navigation and edition in a list of records.

Program array to screen array binding

The INPUT ARRAY sub-dialog binds the members of the flat record (or the primitive member) of an array to the screen-array or screen-record fields specified with the FROM keyword. The number of variables in each record of the program array must be the same as the number of fields in each screen record (that is, in a single row of the screen array).

In most cases you want to bind a program array to a screen-array, in order to display a page of records. However, the INPUT ARRAY instruction can also bind the program array to a simple flat screen-record, to show one record at a time.

The next code example defines an array with a flat record and binds it to a screen array:

PUBLIC TYPE t_items DYNAMIC ARRAY OF RECORD
       item_num INTEGER,
       item_name VARCHAR(50),
       item_price DECIMAL(6,2)
   END RECORD
   ...
DIALOG items_input(p_items t_items)
   INPUT ARRAY p_items FROM sa.*
      BEFORE INSERT
      ...
   END INPUT
   ...
END DIALOG

If the screen array is defined with one field only, you can bind an array defined with a primitive type:

PUBLIC TYPE t_names DYNAMIC ARRAY OF VARCHAR(50)
   ...
DIALOG names_input(p_names t_names)
   INPUT ARRAY p_names FROM sa.*
      BEFORE DELETE
      ...
   END INPUT
   ...
END DIALOG

Identifying an INPUT ARRAY sub-dialog

The name of the screen array specified with the FROM clause will be used to identify the list. For example, the dialog class method such as DIALOG.getCurrentRow("screen-array") takes the name of the screen array as the parameter, to identify the list you want to query for the current row. The name of the screen-array is also used to qualify sub-dialog actions with a prefix.

Control blocks in INPUT ARRAY

Editable record lists declared with the INPUT ARRAY sub-dialog can raise the following triggers:

In the singular INPUT ARRAY instruction, BEFORE INPUT and AFTER INPUT blocks are typically used as initialization and finalization blocks. In the INPUT ARRAY sub-dialog of a DIALOG block, BEFORE INPUT and AFTER INPUT blocks are executed each time the focus goes to (BEFORE) or leaves (AFTER) the group of fields defined by this sub-dialog.