Open dialog box to select CSV file twincat 3

443 Views Asked by At

I am trying to create a recipe handler using arrays and read CSV files, and i am trying from the HMI to create a dialog browser to open a specific folder and then select any .csv file and load it to the array, but I can not find ANY information about it. Does anyone have any info if its possible to do?

I have been searching google a lot and I have been trying to convert code from other languages but I can not get it to work.

I have also tried to make a button to open ANY csv file from the folder as well but I can not get that to work either. As of now I have hardcoded the file to open and that works. But in production the file names will change from every file.

I really hope someone have any solution to this

2

There are 2 best solutions below

0
On

There is a Recipe Manager Extension for the HMI. This extension allows you to load, edit and save recipes from the HMI. I'm not sure if it saves the data in a CSV file in the background.

If you're really tied to csv files, then you would have to build a custom converter to make it work with the Recipe Manager. See an example on how to read and write CSV files here.

Finally there is also the old recipe manager. This doesn't save the recipes in CSV files, but in a custom .txtrecipe format.

0
On

I would suggest a step-back from your current view of things and a reframing.

Rather than going through the process of a dialog browser why not just use an array of strings to populate your paths?

Using FB_EnumFindFileEntry or FB_EnumFindFileList you should be able to find all of the *.csv files inside of a specific folder. With this information you can populate an array and use the selected item from that array to load a specific recipe.