下面的示例演示了如何利用 getfldstate( ) 函数判定字段的内容是否已进行了更改。为满足表缓冲的要求,将 multilocks 设置为 on。打开 testdata 数据库中的
customer 表,然后用 cursorsetprop( ) 函数将缓冲方式设置为开放式表缓冲 (5)。 在 cust_id 字段修改之前发出 getfldstate( ) 函数,显示与此字段的未修改状态相对应的值 (1)。用 replace 命令修改 cust_id 字段后,再次发出
getfldstate( )函数,显示与此字段的修改状态相对应的值 (2)。 之后调用 tablerevert( ) 函数使表返回到原始状态,并且再次发出 getfldstate( ) 函数,显示与 cust_id 字段原始状态相对应的值 (1)。
close databases
set multilocks on && 必须为 on ,以请求表缓冲
set path to (home( ) + 'samples\data\') && 设置数据库的路径
open database testdata && 打开textdata数据库
use customer && 打开customer表
= cursorsetprop('buffering', 5, 'customer') && 启用表缓冲
clear
? getfldstate('cust_id') && 显示1,未作修改
replace cust_id with '***' && 更改字段内容
? getfldstate('cust_id') && 返回2,已修改了该字段
= tablerevert(.t.) && 放弃对表的所有修改
? getfldstate('cust_id') && 显示1,未作修改