Jump to content

"Convert CSV TO UDTF" Ladder function returns "-1"


Recommended Posts

What the main goal is:
To download a CSV file from an external source and then transfer that data into an array which will be used throughout the program.

I assumed my first step was to convert a CSV file to a udtf file and then use the function "Copy column to array". 

However, when I try and use the CSV to UDTF my status bar always shows  "-1", I have a micro SD card in the slot and a USB in another slot with the required CSV file. I also tried just putting the file onto the micro sd card but that also didn't seem to work... 

Am I using the function properly? Any advice would be helpful as this is my first time using Unitronics

Thank you


Link to comment
Share on other sites

26 minutes ago, TylerHPS said:

Turns out the string that I added needed a power up value, the function searches for the power up value of the string and not the actual string name.


Maybe add this to the help file!


That is not correct.

The function takes the current value of the tag. If power up value worked, then it means that your tag originally had no value (it was an empty string).



When the ladder starts, a small piece of code runs, which is the code that sets the power-up value. For example:

MyString = "Hello World";



Now if in another place in the code I do: MyString = "Foo Bar"; 

then now the tag contains FooBar. Convert CSV to UDTF does not know, and could never know what the power up value was.

Tags are placed in memory in an absolute address, so writing a new value (like Foo Bar) overwrites the memory where the string that was set during power up. When calling CSV to UDTF, the pointer (address of the string tag) and its length are being sent to the CSV to UDTF file.


Since setting power-up value made it work, then it means that the code that sets the actual string value is never called, else the new value would have been used and not the power up value. (And this also explains why you had an empty string that caused the error status).


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...