Example: orders.4gl (Function order_check)

This function verifies the values of the order header fields.

Function order_check (orders.4gl)
  1 PRIVATE FUNCTION order_check(d ui.Dialog) RETURNS BOOLEAN
  2   
  3   IF d.getFieldTouched("orders.order_date")
  4    AND order_rec.order_date < TODAY THEN
  5      ERROR msg12
  6      RETURN FALSE
  7   END IF
  8   
  9   RETURN TRUE
 10   
 11 END FUNCTION
Note:
  • Line 1 defines the function with a ui.Dialog object as parameter. The dialog object will be provided by the dialog instruction by passing the DIALOG keyword as parameter. The function returns TRUE if the current order header values are ok.
  • Line 3 verifies if the order date field has been touched: We only want to check values entered by the user. If the date is in the past, we show an error message and return FALSE.
  • Line 9 returns TRUE, indicating that the order heaser fields are ok.