主题:新手问表计算合计和DBF导出的问题
最近接手了一个同事的工作,他有一个对字段“余额”按照字段“标志”相同的进行累加的小程序,不过速度很慢,而且经常跳出“超出记录”的提示(实际已经运行完毕),有高手能有更简便的办法吗?
close data
SET TALK OFF
SET SAFE OFF
CLEAR ALL
CLEAR
SELE 1
*suppose the input DBF file is test.dbf
USE TEST
* ith round, select the ith record
comparation_started = .F.
rec_no = 1
go BOTTOM
rec_no_end = RECNO()
go TOP
do while NOT eof(1)
if (!comparation_started)
*?"...comparation not started!"
* startinf golden record used for comparison
value_zh1 = ALLTRIM(标志)
*value_dz = ALLTRIM(dz)
value_x1 = 余额
comparation_started = .T.
else
*?"...comparation has started!"
* comparation
*?"comparation:value_xm="+value_xm+" value_dz="+value_dz
*?"comparation:xm="+xm+" dz="+dz
if (value_zh1 = ALLTRIM(标志))
value_x3 = value_x1 + 余额
* delete the record
*?"delete record "+str(rec_no)
delete
rec_no_end = rec_no_end-1
endif
endif
skip
*?"Skip"+str(recno())
if eof(1)
*?"EOF"+str(recno())
pack
* modify current record's je value
go rec_no
replace 余额 with value_x1
* go for next record
rec_no = rec_no +1
*? "rec_no="+str(rec_no)
if (rec_no = rec_no_end)
exit
*else
endif
go rec_no
comparation_started = .F.
endif
enddo
?"Done!"
close data
close data
SET TALK OFF
SET SAFE OFF
CLEAR ALL
CLEAR
SELE 1
*suppose the input DBF file is test.dbf
USE TEST
* ith round, select the ith record
comparation_started = .F.
rec_no = 1
go BOTTOM
rec_no_end = RECNO()
go TOP
do while NOT eof(1)
if (!comparation_started)
*?"...comparation not started!"
* startinf golden record used for comparison
value_zh1 = ALLTRIM(标志)
*value_dz = ALLTRIM(dz)
value_x1 = 余额
comparation_started = .T.
else
*?"...comparation has started!"
* comparation
*?"comparation:value_xm="+value_xm+" value_dz="+value_dz
*?"comparation:xm="+xm+" dz="+dz
if (value_zh1 = ALLTRIM(标志))
value_x3 = value_x1 + 余额
* delete the record
*?"delete record "+str(rec_no)
delete
rec_no_end = rec_no_end-1
endif
endif
skip
*?"Skip"+str(recno())
if eof(1)
*?"EOF"+str(recno())
pack
* modify current record's je value
go rec_no
replace 余额 with value_x1
* go for next record
rec_no = rec_no +1
*? "rec_no="+str(rec_no)
if (rec_no = rec_no_end)
exit
*else
endif
go rec_no
comparation_started = .F.
endif
enddo
?"Done!"
close data