FIELD (return control with focus)

Top  Previous  Next

 

FIELD( )

The FIELD procedure returns the field number of the control which has focus at the time of any field-specific event. This includes both the EVENT:Selected and EVENT:Accepted events. FIELD returns zero (0) for field-independent events.

Positive field numbers are assigned by the compiler to all WINDOW controls, in the order their declarations occur in the WINDOW structure. Negative field numbers are assigned to all APPLICATION controls. In executable code statements, field numbers are usually represented by field equate labels--the label of the USE variable preceded by a question mark (?FieldName).

Return Data Type:

SIGNED

Example:

Screen WINDOW

       ENTRY(@N4),USE(Control1)

       ENTRY(@N4),USE(Control2)

       ENTRY(@N4),USE(Control3)

       ENTRY(@N4),USE(Control4)

      END

CODE

ACCEPT

 IF NOT ACCEPTED()

  CYCLE

 END

 CASE FIELD()          !Control edit control

  OF ?Control1         !Field number 1

   IF Control1 = 0     !if no entry

    BEEP               !sound alarm

    SELECT(?)          !stay on control

   END

 OF ?Control2          !Field number 2

  IF Control2 > 4      !if status is more than 4

   Scr:Message = 'Control must be less than 4'

   ERASE(?)            !clear control

   SELECT(?)           !edit the control again

  ELSE                 !value is valid

   CLEAR(Scr:Message)  !clear message

  END

 OF ?Control4          !Field number 4

  BREAK                !exit processing loop

 END

END                    !end case, end loop

 

See Also:

ACCEPT

ACCEPTED

SELECTED

FOCUS

EVENT