下面示例演示如何用 setfldstate( ) 改变字段状态。将 multilocks 设置为 on 是表缓冲的要求,然后打开
testdata 数据库中的 customer 表,并用 cursorsetprop( ) 把缓冲方式设置成开放式表缓冲 (5)。
getfldstate( ) 用来获取字段状态,这时显示一个值 (1),表明 cust_id 字段未修改。在 cust_id 字段用 replace
修改之后,再次使用 getfldstate( ),这时显示一个值 (2),它表明 cust_id 字段已修改。
setfldstate( ) 用来把 cust_id 字段的状态改回 1 (未修改)。调用 getfldstate( ) 后,显示值为 1,这与用
setfldstate( ) 指定的 cust_id 字段状态相对应。tablerevert( ) 用来恢复表的原始状态。
close databases
set multilocks on && 为表缓冲必须设置为 on
set path to (home( ) + 'samples\data\') && 设置数据库的路径
open database testdata && 打开 testdata 数据库
use customer && 打开 customer 表
= cursorsetprop('buffering', 5, 'customer') && 启用表缓冲
clear
? getfldstate('cust_id') && 显示 1,未修改
replace cust_id with '***' && 更改字段内容
? getfldstate('cust_id') && 返回 2,字段已修改
= setfldstate('cust_id', 1) && 更改字段状态
? getfldstate('cust_id') && 显示 1,未修改
= tablerevert(.t.) && 放弃所有对表的修改