|Navigation: Language Reference > 13 - Built-in Functions >====== FIELD (return control with focus) ======|
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|
IF NOT ACCEPTED()
CASE FIELD() !Control edit control
OF ?Control1 !Field number 1
IF Control1 = 0 !if no entry
BEEP !sound alarm
SELECT(?) !stay on control
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
OF ?Control4 !Field number 4
BREAK !exit processing loop
END !end case, end loop