救救我!!我有一个不太难的问题,谁能帮帮我.分数好说,我有3000多分
这个程序是通过3个参数其实为三个目录.(备份目录,源目录,目的目录)
将其中的源目录的多个dbf文件(数据结构一样)合并成一个文件放在目的目录里.
合并的文件的名称以日期决定.若已有了,便加后缀"_1",依次类推.
然后将源目录的文件移到备份目录里.
下面是我写的代码,因为我没学过vf,请各位大侠帮帮忙.
*汇总程序2003-01-20
PARAMETER sourPathParm,destPathParm,joinPathParm
SourPath = sourPathParm
DestPath = destPathParm
JoinPath = joinPathParm
messagebox(SourPath)
messagebox(DestPath)
messagebox(JoinPath)
FileName = sys(2000,SourPath+"*.db?")
messagebox(FileName)
WorkFlag = 0
do while len(FileName) > 0
*messagebox("文件名="+FileName)
SourFile = SourPath+FileName
*messagebox("源路径="+SourFile)
DestFile = DestPath+FileName
*messagebox("目标路径="+DestFile)
*第一次循环是要决定目标文件(合并后的文件)的名称
if WorkFlag = 0 then
WorkFlag = 1
JoinFile = JoinPath + TStamp() + "_" + str(WorkFlag,1) + ".dbf"
do while file(JoinFile)
WorkFlag = WorkFlag+1
JoinFile = JoinPath + TStamp() + "_" + str(WorkFlag,1) + ".dbf"
enddo
messagebox(JoinFile)
copy file "" + SourFile to "" + JoinFile
*打开数据库.
use "" + JoinFile
else
messagebox(SourFile)
*追加记录
appe from "" + SourFile
endif
* DestFile应该是备份路径
copy file "" + SourFile to "" + DestFile
dele file "" + SourFile
FileName = sys(2000, SourPath + "*.dbf", 0)
endd
*如果记录数大于0,便显示数据
if recno() > 0 then
brow
messagebox("brow OK")
endif
use
*messagebox("OK")
*------------------------------------
FUNCTION TStamp
PARAMETER wzpdate,wzptime
PRIVATE d,t
m.d = IIF( EMPTY( m.wzpdate), DATE(), m.wzpdate)
m.t = IIF( EMPTY( m.wzptime), TIME(), m.wzptime)
TODAY = str( Year( m.d), 4) + str( Month( m.d), 2) + str( Day( m.d),2)
if Left( Right(TODAY, 4), 1) = " " then
TODAY = Left( TODAY, 4) + "0" + Right(TODAY, 3)
endif
if Left(Right(TODAY, 2), 1) = " " then
TODAY = Left(TODAY, 6) + "0" + Right(TODAY,1)
endif
return TODAY
* RETURN ((YEAR(m.d)-1980) * 2 ** 25)+(MONTH(m.d) * 2 ** 21) + (DAY(m.d) * 2 ** 16) + (VAL(LEFT(m.t,2)) * 2 ** 11) + (VAL(SUBSTR(m.t,4,2)) * 2 ** 5) + VAL(RIGHT(m.t,2))
ENDFUNC && TStamp
*------------------------------------