version 3
Old (field) Expression
Parameter | Type | Description | |
field | Field | Field for which to return old value | |
Function result | Expression | Original field value |
Description
The Old command returns the value held in field before the field was programmatically assigned a value or modified in data entry.
Each time you change the current record for a table, 4D creates and maintains in memory a duplicated "image" of the new current record when it is loaded in memory. (For optimization, 4D disregards Text, Picture and BLOB fields.) When modifying a record, you work with the actual image of the record, not this duplicated image. This image is then discarded when you change the current record again.
Old returns the value from the duplicated image. In other words, for an existing record, it returns the value of the field as it is stored on disk. If a record is new, Old returns the default empty value for field according to its type. For example, if field is an Alpha field, Old returns an empty string. If field is a numeric field, Old returns zero (0), and so on.
Old works on field whether the field has been modified by a method or by the user during data entry.
Old cannot be applied to Text, Picture or BLOB fields. It can be applied to all other field types, including subfields, but has no meaning when applied to a subtable field itself.
To restore the original value of a field, assign it the value returned by Old.
See Also