Search code examples
user-interfacewonderware

Using FileReadFields with Wonderware


I suppose this is a long shot considering how few Wonderware questions I've seen on here, but anyway...

The FileReadFields function in Wonderware is supposed to parse a CSV file into memory tags. There are no debug messages when stuff doesn't work in Wonderware (not my choice of HMI software, that's for sure), so I have no idea why this isn't working:

FileReadFields("C:\NASA\Sample.csv", 0, Profile_Setup_Name, 1);

Everything is cased correctly and the file is not in-use. I can't figure out how to make it work.


Solution

  • FileReadFields function is used to read several values from a CSV file into a series of tagnames. You can not store those values into just one tag. Because a CSV file can contain several values per line, you need more than one tagname to receive all the values. Those tagnames must end in a number (i.e. MyTag1, MyTag2, MyTag3, ...). Additionally, the tagname must be enclosed with double quotes

    This is a correct example:

    FileReadFields("C:\NASA\Sample.csv", 0, "MyTag1", 1);

    Where MyTag1 is the first tagname. You have to create MyTag1, MyTag2, MyTag3....