Dataport, Multiple Files

Hi, I need to write a dataport that will access a file directory and sequentially process and import any files that are contained within that directory. How do I do this?

you should write a code like this: rFile is record on File table (virtual table). By default it looks empty, but when you set filter on path is shows the contents of that path. rFile.SETRANGE(Path,'C:\MyFolder'); rFile.SETRANGE("Is a file",TRUE); IF rFile.FIND('-') THEN REPEAT ProcessFile(rFile.Path + '\' + rFile.Name); UNTIL lrFile.NEXT = 0; the function processfile could call your dataport or open file manually and parse the data…

I am having a problem w/ basic syntax for a dynamic file open. I’ve put several versions of logic in PreDataItem. Example: rFile.SETRANGE(Path,‘C:\Temp’); rFile.SETRANGE(Name,‘Create01.txt’); rFile.SETRANGE(“Is a file”,TRUE); CurrFile.OPEN(CurrFile.NAME); Keep getting ‘…operating system cannot find the drive and directory’. I’ve verified that path & file exist; works when specified on input form. I’ve verified through MESSAGE’s that the dynamic path & name are identical to path & name when specified on input. What is issue here?

Alastair pointed out to me that the example provided was incomplete; missing FIND. Here is complete text: rFile.SETRANGE(Path,‘C:\Temp’); rFile.SETRANGE(Name,‘Create01.txt’); rFile.SETRANGE(“Is a file”,TRUE); CurrFile.WRITEMODE := TRUE; IF rFile.FIND(’-’) THEN BEGIN CurrFile.OPEN(CurrFile.NAME); Anyone know why this dynamic name will not work?

Try : CurrFile.OPEN(rFile.Name) instead of CurrFile.OPEN(CurrFile.NAME); Tarek

quote:


Originally posted by larryi
CurrFile.OPEN(CurrFile.NAME); Anyone know why this dynamic name will not work?


A belated thanks to all who helped out on this. Finally got this to work! In the process, found out that trying to do this in a Dataport doesn’t work very well; can only do this in InitDataPort. Had to switch over to writing a Report; worked fine.