The information in this article applies to:
- Microsoft FoxPro for Windows, versions 2.5, 2.5a
- Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, 2.5a
SUMMARY
The UPDATED() function returns .T. if any GET field was changed during a
READ command. Since push buttons, radio buttons, lists, invisible buttons,
and spinners (spin boxes) are considered GET fields, UPDATED() will also
return .T. if any of these controls are accessed during a READ command.
MORE INFORMATION
To write a simple code snippet to verify if any data in the current record
was changed during a READ command, do the following:
- When the record pointer is moved to a record, scatter the data to an
array by issuing the following command:
SCATTER TO beg_edit MEMO && MEMO is required only if memo
&& fields are being verified.
If the record pointer is pointing to the same record in more than one
session, move the record pointer off the record and then back in order
to get current information:
SKIP && provided we are not at EOF()
SKIP -1 && to return to the same record
&& Now the second SCATTER will work correctly.
- After all changes are complete, issue the following commands. Normally
this code snippet would appear in the VALID clause of a push button or
other control labeled to save the changes.
* Scatter to a second array for comparison.
SCATTER TO end_edit MEMO
* Check each element in the array against the original data.
FOR i = 1 TO alen(beg_edit)
IF beg_edit(i) <> end_edit(i)
* Return .F. if any element has changed.
RETURN .F.
ENDIF
ENDFOR
RETURN .T.
To check for changes during a BROWSE, execute the code in step 1 in a
BROWSE WHEN user-defined function (UDF). Execute the code in step 2 in
a BROWSE VALID UDF.
Notes
- A set of two arrays is used for simplicity and portability. By using two
arrays, the same code will work with any database, regardless of field
names, field types, or number of fields.
- Caution must be used when scattering large memo fields. If there is
insufficient memory to hold the entire contents of the memo field, the
memo field will not be scattered.
- SET EXACT should be set to ON in order to eliminate the possibility of
strings of different length comparing as equal.
For more information, see the version 2.0 "Commands & Functions" manual or
the version 2.5 "Language Reference" manual.
|