Passing a dialog reference to functions

Using the DIALOG keyword outside a dialog instruction block results in a compilation error. However, you can pass the object to a function that defines the dialog parameter with the ui.Dialog type.

The next example passes the DIALOG object reference to the setupDialog() function, which implements action activation rules that must be applied after different events, during the dialog execution:
INPUT BY NAME custid, custname, custaddr 
  BEFORE INPUT
    CALL setupDialog(DIALOG)
  ...
  ON ACTION check_address
    ...
    CALL setupDialog(DIALOG)
  ...
END INPUT

FUNCTION setupDialog(d)
  DEFINE d ui.Dialog 
  DEFINE isAdmin BOOLEAN
  LET isAdmin = (global_params.user_group == "admin")
  CALL d.setActionActive("delete", isAdmin)
  CALL d.setActionActive("convert", isAmdin)
  CALL d.setActionActive("check_address",
          isAdmin AND rec.custaddr IS NOT NULL)
END FUNCTION