Example 2: INPUT with binding by field name

Form definition file "custlist.per" (same as in Example 1)

Program source code:
SCHEMA shop 

MAIN

  DEFINE custrec RECORD LIKE customer.*
  DEFINE upd INTEGER

  DATABASE shop 
  OPTIONS INPUT WRAP
  OPEN FORM f FROM "form1"
  DISPLAY FORM f 

  LET custrec.id = arg_val(1)
  LET upd = (custrec.id < 0)

  LET INT_FLAG = FALSE
  INPUT BY NAME custrec.* ATTRIBUTES(UNBUFFERED, WITHOUT DEFAULTS=upd)
    BEFORE INPUT
      MESSAGE "Enter customer information..."
      IF upd THEN
         SELECT fname, lname INTO custrec.fname, customer.lname 
            FROM customer WHERE customer.id = custrec.id
      END IF
    AFTER FIELD fname 
      IF FIELD_TOUCHED(custrec.fname) AND custrec.fname IS NULL THEN
        LET custrec.lname = NULL
      END IF
    AFTER INPUT
      MESSAGE "Input terminated..."
  END INPUT

  IF INT_FLAG = FALSE THEN
    DISPLAY custrec.*
    LET INT_FLAG = FALSE
  END IF

END MAIN