CurVal(), OldVal()
These functions give you access to the extra buffers that FoxPro maintains for buffered records and tables. CURVAL() tells you the current value of a field on disk, while OLDVAL() tells you the value a field had the last time you retrieved it from disk.
Usage |
uValue = CURVAL( cExpr [ , cAlias | nWorkArea ] ) uValue = OLDVAL( cExpr [ , cAlias | nWorkArea ] ) |
You're not restricted to passing a single field name to these functions. They actually can return information about an expression. Whatever you pass, note that they expect a character string, not a name. |
VFP 7 Service Pack 1 fixes a bug that can cause data corruption under very obscure circumstances (in fact, we heard of this only when we saw it on the list of bugs fixed in the service pack): Calling OLDVAL() in a transaction involving at least 100 appended records when the internal name table is nearly full (that is, you've created a very large number of variables or objects). |
Example |
USE Employee SET MULTILOCKS ON ? CURSORSETPROP("Buffering", 3) * Make some changes to a record. * Now see what happened to Last_Name field. * Note that there are two cases which are NOT mutually exclusive. IF Last_Name <> OLDVAL("Last_Name") WAIT WINDOW "You changed the last name" ENDIF IF OLDVAL("Last_Name") <> CURVAL("Last_Name") WAIT WINDOW "Someone else changed last name" ENDIF |
See Also |
Buffering, CursorSetProp(), GetFldState(), TableRevert(), TableUpdate() |