FIELD_TOUCHED()

FIELD_TOUCHED() operator tests whether the user has changed any values in a specified form field or fields.

This operator can only be used within CONSTRUCT, INPUT, and INPUT ARRAY statements.

When you use it, 4GL assumes that you are referring to the current screen record rather than to a different row of the screen array.

Description: FIELD_TOUCHED%20Operator

Here

 

FIELD_TOUCHED() can be used after the data was displayed to the specified fields by the DISPLAY statement.

 

If the user has changed the contents of a field, FIELD_TOUCHED() will return TRUE.

FIELD_TOUCHED() can also return TRUE when the cursor is in the specified field and the user press any of these keys:

After any of these keys were pressed, FIELD_TOUCHED() returns TRUE when the keystroke has actually changed the value in the field. Otherwise, FIELD_TOUCHED() returns FALSE.

Moving through a field by means of RETURN, TAB, or the arrow keys does not edit the field, and FIELD_TOUCHED() returns TRUE.

 

FIELD_TOUCHED() does not register the effect of 4GL statements that appear in BEFORE CONSTRUCT or BEFORE INPUT clauses. You can assign values to fields in these clauses without marking the fields as touched.

 

Here is a simple example of using the FIELD_TOUCHED() operator.

In this example, the IF operator checks whether the field value was changed. If the field value was changed, you will get the message – "You have altered the field...". Otherwise, no messages are displayed.

4gl code

MAIN

  DEFINE rec1 RECORD

    f1 CHAR(10),

    f2 CHAR(10),

    f3 CHAR(10),

    f4 CHAR(10)

  END RECORD

 

  LET rec1.f1 = "Field f1"

  LET rec1.f2 = "Field f2"

  LET rec1.f3 = "Field f3"

  LET rec1.f4 = "Field f4"

 

  OPEN WINDOW w_test

    AT 2, 2

    WITH FORM "field_touched_operator"

     

      DISPLAY "Modify a field and press Return" AT 15,5

 

  INPUT BY NAME rec1.* WITHOUT DEFAULTS

    AFTER FIELD f1

      IF FIELD_TOUCHED(f1) THEN

        ERROR "You have altered the field f1"

      END IF

    AFTER FIELD f2

      IF FIELD_TOUCHED(f2) THEN

        ERROR "You have altered the field f2"

      END IF

    AFTER FIELD f3

      IF FIELD_TOUCHED(f3) THEN

        ERROR "You have altered the field f3"

      END IF

    AFTER FIELD f4

      IF FIELD_TOUCHED(f4) THEN

        ERROR "You have altered the field f4"

      END IF

  END INPUT

 

  CLOSE WINDOW w_test

END MAIN

.per form

DATABASE formonly

 

SCREEN

{

Field f1: [f1        ]

Field f2: [f2        ]

Field f3: [f3        ]

Field f4: [f4        ]

}

 

ATTRIBUTES

f1 = formonly.f1;

f2 = formonly.f2;

f3 = formonly.f3;

f4 = formonly.f4;

 

INSTRUCTIONS

 

DELIMITERS "[]"

 

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.