I've got a process that needs to run every single day importing files that are pulled down from an FTP site into the same folder. I've got the entire project down and done except for grabbing the files.

Is there any way that I can make FoxPro grab files in a format like this: appointmentlist_METER_05152013.txt appointmentlist_RADIO_05132013.txt

These files are in this folder every morning at 6am, but I need to make sure that I get the METER one for one of the FoxPro programs, and the other one should grab RADIO. The only thing that changes daily is the date in the filename.

If need be I can make sure that each file is pulled into a different folder in the FTP retrieval process, and that each of those folders only contain the file for that day in them.

Any help would be greatly appreciated.

If you need anymore information please feel free to ask.

有帮助吗?

解决方案

You can use the ADIR() function to create an array of files on a certain drive and directory.

 SET DEFAULT TO c:\Mydirectory
 MyFilesCount = ADIR(MyArray, '*.TXT')   &&Get all TXT files at this location

You can then loop thru the above array and search for a file containing a certain string using the ATC() function.

 FOR n = 1 TO MyFilesCount
      IF ATC("METER", MyArray[n,1] ) > 0    &&First column contains file name
         ***Run METER process
      ENDIF
      IF ATC("RADIO", MyArray[n,1] ) > 0   &&First column contains file name
         ***Run RADIO process
      ENDIF
 ENDFOR

其他提示

m.CDATE = Transform(Day(Date()), '@L 99') + Transform(Month(Date()), '@L 99') + Transform(Year(Date()), '@L 9999')

m.CFILE = 'C:\SOMEFOLDER\appointmentlist_RADIO_' + M.CDATE + '.txt'

If File(M.CFILE) Then
    Do RADIOPROCESS With m.CFILE
Endif

m.CFILE = 'C:\SOMEFOLDER\appointmentlist_METER_' + M.CDATE + '.txt'

If File(M.CFILE) Then
    Do METERPROCESS With m.CFILE
Endif
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top