ON CHANGE block

The ON CHANGE block can be used to detect that a field changed by user input. The ON CHANGE block is executed if the value has changed since the field got the focus and if the modification flag is set. The ON CHANGE block can only be used for fields controlled by an INPUT or INPUT ARRAY dialog, it is not available in CONSTRUCT.

For editable fields defined as EDIT, TEXTEDIT or BUTTONEDIT, the ON CHANGE block is executed when leaving a field, if the value of the specified field has changed since the field got the focus and if the modification flag is set for the field. You leave the field when you validate the dialog, when you move to another field, or when you move to another row in an INPUT ARRAY.

For editable fields defined as CHECKBOX, COMBOBOX, DATEEDIT, RADIOGROUP, SPINEDIT, SLIDER or TIMEEDIT, the ON CHANGE block is invoked immediately when the user changes the value with the widget edition feature. For example, when toggling the state of a CHECKBOX, when selecting an item in a COMBOBOX list, or when choosing a date in the calendar of a DATEEDIT. Note that for such item types, when ON CHANGE is fired, the modification flag is always set.

The dialogtouched predefined action can also be used to detect field changes immediately, but with this action you can't get the data in the target variables; this special action should only be used to detect that the user has started to modify data in the current dialog.

If both an ON CHANGE block and AFTER FIELD block are defined for a field, the ON CHANGE block is executed before the AFTER FIELD block.

When changing the value of the current field by program in an ON ACTION block, the ON CHANGE block will be executed when leaving the field if the value is different from the reference value and if the modification flag is set (after previous user input or when the touched flag has been changed by program).

When using the NEXT FIELD instruction, the comparison value is reassigned as if the user had leaved and reentered the field. Therefore, when using NEXT FIELD in ON CHANGE block or in an ON ACTION block, the ON CHANGE block will only be invoked again if the value is different from the reference value. This denies to do field validation in ON CHANGE blocks: you must do validations in AFTER FIELD blocks and/or AFTER INPUT blocks.

INPUT ARRAY arr.* WITHOUT DEFAULTS
      FROM sr.* ATTRIBUTES(UNBUFFERED)
   ...
   ON CHANGE order_checked -- Defined as CHECKBOX
      CALL setup_dialog(DIALOG)
   ...
END INPUT