My client downoads txt files from their mother company, these files contain info on money transfer... Every day he receives many files... the file name are
yymmddnum.txt exemple today 060927400.txt...
the num digit keeps incrementing...
for exemple today he might get 15 files there fore up to 060927415.txt... that is until he closes his office at 4 p.m. but mother company keeps sending files, so the next morning he has to download the files of yesterday that weren't downloaded and the ones for today...
what i did and it is not good, and I'll explain later..
I have a table where I keep all the file name that were imported, so has to prevent the import of the same file many time...
I take the name of the last file imported and get the Number after the date...my problem is when the month changes- for exemple my client will get file on sept 30th 060930NU.txt that he will have to download, but with the way code is for october nothing will be downloaded... and I need to give year and month at least so has not to download 200 files or more, because parent company leaves all files in directory... or is there an FTP command to delete the files from parent directory once downloaded so I do not have to care about the file name , or if NU=40 in order to get files with number 410 and up had to add Nu+1 and redo same thing...
Is there a way to simplify this code....
tbl=table.open("Impfilenametbl.dbf")
tbl.fetch_Lats()
Fname=tbl.Impfilename
da=date()
y=substr(da,5,2)
m=substr(da,3,2)
d=Substr(da,1,2)
NU = Val(substr(fname,7,2))
tbl.close()
if Val(m)<>2 .and. Val(m)<>4 .and. Val(m) <>6 .and. Val(m) <> 9 .and. Val(m) <>11 .and. Val(D) < 32 then
Fl= ftp_get_Nlist("0.0.0.0","Username","Password","/")
fp=filter_string_match(fl,y+m+"*"+NU+"*.txt",crlf())
t=line_count(fp)
else if Val(m)<>1 .and. Val(m)<>3 .and. Val(m) <>5 .and. Val(m) <> 7 .and. Val(m) <>8 .and. Val(m) <>10 .and. Val(m) <>12 .and. Val(D) < 31 then
Fl= ftp_get_Nlist("0.0.0.0","Username","Password","/")
fp=filter_string_match(fl,y+m+"*"+NU+"*.txt",crlf())
t=line_count(fp)
else Val(m) = 2 .and. Val(d) <29
Fl= ftp_get_Nlist("0.0.0.0","Username","Password","/")
fp=filter_string_match(fl,y+m+"*"+NU+"*.txt",crlf())
t=line_count(fp)
end if
for each fa in fp
Gfile="/"+fa
Tfile="C:\Program files\AlphaUno\JGNT\ "
Fdest=Trim(Tfile)+fa
cmd=ftp_get_file("0.0.0.0","Username","Password",Gfile,Fdest)
Ftp_Script_run("Downloading",cmd,.f.)
next
Nu= Nu+1
if Val(m)<>2 .and. Val(m)<>4 .and. Val(m) <>6 .and. Val(m) <> 9 .and. Val(m) <>11 .and. Val(D) < 32 then
Fl= ftp_get_Nlist("0.0.0.0","Username","Password","/")
fp=filter_string_match(fl,y+m+"*"+NU+"*.txt",crlf())
t=line_count(fp)
else if Val(m)<>1 .and. Val(m)<>3 .and. Val(m) <>5 .and. Val(m) <> 7 .and. Val(m) <>8 .and. Val(m) <>10 .and. Val(m) <>12 .and. Val(D) < 31 then
Fl= ftp_get_Nlist("0.0.0.0","Username","Password","/")
fp=filter_string_match(fl,y+m+"*"+NU+"*.txt",crlf())
t=line_count(fp)
else Val(m) = 2 .and. Val(d) <29
Fl= ftp_get_Nlist("0.0.0.0","Username","Password","/")
fp=filter_string_match(fl,y+m+"*"+NU+"*.txt",crlf())
t=line_count(fp)
end if
for each fa in fp
Gfile="/"+fa
Tfile="C:\Program files\AlphaUno\JGNT\ "
Fdest=Trim(Tfile)+fa
cmd=ftp_get_file("0.0.0.0","Username","Password",Gfile,Fdest)
Ftp_Script_run("Downloading",cmd,.f.)
next
yymmddnum.txt exemple today 060927400.txt...
the num digit keeps incrementing...
for exemple today he might get 15 files there fore up to 060927415.txt... that is until he closes his office at 4 p.m. but mother company keeps sending files, so the next morning he has to download the files of yesterday that weren't downloaded and the ones for today...
what i did and it is not good, and I'll explain later..
I have a table where I keep all the file name that were imported, so has to prevent the import of the same file many time...
I take the name of the last file imported and get the Number after the date...my problem is when the month changes- for exemple my client will get file on sept 30th 060930NU.txt that he will have to download, but with the way code is for october nothing will be downloaded... and I need to give year and month at least so has not to download 200 files or more, because parent company leaves all files in directory... or is there an FTP command to delete the files from parent directory once downloaded so I do not have to care about the file name , or if NU=40 in order to get files with number 410 and up had to add Nu+1 and redo same thing...
Is there a way to simplify this code....
tbl=table.open("Impfilenametbl.dbf")
tbl.fetch_Lats()
Fname=tbl.Impfilename
da=date()
y=substr(da,5,2)
m=substr(da,3,2)
d=Substr(da,1,2)
NU = Val(substr(fname,7,2))
tbl.close()
if Val(m)<>2 .and. Val(m)<>4 .and. Val(m) <>6 .and. Val(m) <> 9 .and. Val(m) <>11 .and. Val(D) < 32 then
Fl= ftp_get_Nlist("0.0.0.0","Username","Password","/")
fp=filter_string_match(fl,y+m+"*"+NU+"*.txt",crlf())
t=line_count(fp)
else if Val(m)<>1 .and. Val(m)<>3 .and. Val(m) <>5 .and. Val(m) <> 7 .and. Val(m) <>8 .and. Val(m) <>10 .and. Val(m) <>12 .and. Val(D) < 31 then
Fl= ftp_get_Nlist("0.0.0.0","Username","Password","/")
fp=filter_string_match(fl,y+m+"*"+NU+"*.txt",crlf())
t=line_count(fp)
else Val(m) = 2 .and. Val(d) <29
Fl= ftp_get_Nlist("0.0.0.0","Username","Password","/")
fp=filter_string_match(fl,y+m+"*"+NU+"*.txt",crlf())
t=line_count(fp)
end if
for each fa in fp
Gfile="/"+fa
Tfile="C:\Program files\AlphaUno\JGNT\ "
Fdest=Trim(Tfile)+fa
cmd=ftp_get_file("0.0.0.0","Username","Password",Gfile,Fdest)
Ftp_Script_run("Downloading",cmd,.f.)
next
Nu= Nu+1
if Val(m)<>2 .and. Val(m)<>4 .and. Val(m) <>6 .and. Val(m) <> 9 .and. Val(m) <>11 .and. Val(D) < 32 then
Fl= ftp_get_Nlist("0.0.0.0","Username","Password","/")
fp=filter_string_match(fl,y+m+"*"+NU+"*.txt",crlf())
t=line_count(fp)
else if Val(m)<>1 .and. Val(m)<>3 .and. Val(m) <>5 .and. Val(m) <> 7 .and. Val(m) <>8 .and. Val(m) <>10 .and. Val(m) <>12 .and. Val(D) < 31 then
Fl= ftp_get_Nlist("0.0.0.0","Username","Password","/")
fp=filter_string_match(fl,y+m+"*"+NU+"*.txt",crlf())
t=line_count(fp)
else Val(m) = 2 .and. Val(d) <29
Fl= ftp_get_Nlist("0.0.0.0","Username","Password","/")
fp=filter_string_match(fl,y+m+"*"+NU+"*.txt",crlf())
t=line_count(fp)
end if
for each fa in fp
Gfile="/"+fa
Tfile="C:\Program files\AlphaUno\JGNT\ "
Fdest=Trim(Tfile)+fa
cmd=ftp_get_file("0.0.0.0","Username","Password",Gfile,Fdest)
Ftp_Script_run("Downloading",cmd,.f.)
next
Comment