bof( ) 函数示例

下面的示例打开 customer 表并显示一个窗口,使用命令按钮可以向前或向后移动表的记录指针,根据记录指针移动的方向,visual foxpro 测试该指针是在文件末尾 (eof) 还是在文件头 (bof)。如果任一条件为“真”(.t.),visual fexpro 显示正确的内容,并移动记录指针到一个新的位置。

close databases
open database (home( ) + 'samples\data\testdata')
use customer && 打开 customer 表
set talk off
clear
activate screen
@ 2,1 say 'company: '+ company
define window wskip from 9,10 to 14,65 double color scheme 5
activate window wskip
@ 1,5 get gnchoice function '*hn \<forward;\<backward;\<quit' ;
default 0 size 2,14 valid choice( )
read cycle
release window wskip

procedure choice
do case
case gnchoice = 1
skip
if eof('customer')
wait window 'end of file encountered' nowait
skip -1
endif
case gnchoice = 2
skip -1
if bof('customer')
wait window 'beginning of file encountered' nowait
go top

endif
case gnchoice = 3
clear read
endcase
activate screen
@ 2,1 clear to 2,50
@ 2,1 say 'company: '+ company
return .t.