User Tools

Site Tools


field_return_control_with_focus_.htm
Navigation:  Language Reference > 13 - Built-in Functions >====== FIELD (return control with focus) ====== Previous pageReturn to chapter overviewNext page

NewC7.jpg

FIELD( )

blk2blue.jpg

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

field_return_control_with_focus_.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1