SETFLDSTATE( ) Function Example

The following example demonstrates how you can use SETFLDSTATE( ) to change the field status. MULTILOCKS is set to ON, a requirement for table buffering. The customer table in the testdata database is opened, and CURSORSETPROP( ) is then used to set the buffering mode to optimistic table buffering (5).

GETFLDSTATE( ) is issued to display a value (1) corresponding to the unmodified state of the cust_id field before it is modified. The cust_id field is modified with REPLACE, and GETFLDSTATE( ) is issued again to display a value (2) corresponding to the modified state of the cust_id field.

SETFLDSTATE( ) is used to change the field status of the cust_id field back to 1 (unmodified). GETFLDSTATE( ) is issued again and displays 1, corresponding to the state of the cust_id field assigned by SETFLDSTATE( ). TABLEREVERT( ) is used to return the table to its original state.

CLOSE DATABASES
SET MULTILOCKS ON  && Must be on for table buffering
SET PATH TO (HOME(2) + 'Data\')     && Sets path to database
OPEN DATABASE testdata  && Open testdata database
USE Customer     && Open customer table
= CURSORSETPROP('Buffering', 5, 'customer')  && Enable table buffering

CLEAR
? GETFLDSTATE('cust_id')  && Displays 1, not modified
REPLACE cust_id    WITH '***'  && Changes field contents
? GETFLDSTATE('cust_id')  && Returns 2, field modified
= SETFLDSTATE('cust_id', 1)  && Change the field status
? GETFLDSTATE('cust_id')  && Displays 1, not modified
= TABLEREVERT(.T.)  && Discard all table changes