mline( ) 函数示例

下面的示例中,使用两种方法从备注字段中返回行内容。使用 mline( ) 在两个循环中返回备注字段的行。注意在第二个循环中使用系统内存变量 mline 作为 mline( ) 的参数,从而增强了性能。

clear
set talk off
set memowidth to 50
close databases
create table tmemo (name c(10), notes m)
append blank && 添加一个记录
wait window 'filling memo field - takes several seconds' nowait
***填充备注字段 ***
for gnouterloop = 1 to 5 && 循环 5 次
for gnalphabet = 65 to 75 && 从字符 a 到 h
replace notes with replicate(chr(gnalphabet), 10) ;
+ chr(13) additive
next
next

*** 显示备注字段的所有行***

store memlines(notes) to gnnumlines && 备注字段的行数

store seconds( ) to gnbegin && 开始时间
for gncount = 1 to gnnumlines && 执行备注字段行数次循环
? mline(notes, gncount) && 显示每一行
next
? str(seconds( ) - gnbegin, 4, 2) + ' seconds' && 总时间

*** 更好的方法是在 mline( ) 中使用 mline***
*** 显示备注字段的所有行***

wait 'press a key to see the preferred method' window
clear
store 0 to _mline && 置 mline为 0
store seconds( ) to gnbegin && 开始时间

for count = 1 to gnnumlines && 执行备注字段行数次循环
? mline(notes, 1, _mline) && 显示每一行
next
? str(seconds( ) - gnbegin, 4, 2) + ' seconds' && 总时间
set talk on
close databases
erase tmemo.dbf
erase tmemo.fpt