下面的示例用 fread( ) 函数显示文件内容。如果文件为“空”,则提示相应信息。
*** test.txt 文件必须存在 ***
store fopen('test.txt') to gnfilehandle && 打开该文件
store fseek(gnfilehandle, 0, 2) to gnend && 把指针移到 eof
store fseek(gnfilehandle, 0) to gntop && 把指针移到 bof
if gnend <= 0 && 文件“空”吗?
wait window 'this file is empty!' nowait
else && 如果不“空”
gcstring = fread(gnfilehandle, gnend) && 读入内存
? gcstring
endif
= fclose(gnfilehandle) && 关闭该文件