07-17-2014 03:23 AM
Hey guys,
I just had a quick question regarding appending header to a binary file with string data written to it.
As you can see I can read the files correctly if I set "prepend array or string text size" to TRUE.
but when I set it to false, an error occurs.
I thought each string is assumed to be 1byte, so if I pass the file size in bytes to the read function, it would return me the correct number of strings. Which assumption of mine is incorrect?
Thanks for your help
07-17-2014 06:33 AM
Your problem is you are trying to read the string as a binary. When you do that, it needs to see the string size at the start. If you use the Read Text File instead, then you tell it how many characters to read.
So the lesson here really is when using text, use the Write/Read Text File. When using binary data, use the Write/Read Binary File.
07-20-2014 08:08 PM
So the lesson here really is when using text, use the Write/Read Text File. When using binary data, use the Write/Read Binary File.
I totally agree with you. I was only doing this because there was another minute problem I was trying to avoid.
07-20-2014 08:59 PM
Hi,
If you remove the wire going to the data type on the binary read vi in the second example, I think it will work. If you wire a string constant to the data type it reads an array of strings. If you don't wire anything it outputs a flattened string. It's always seemed kind of buggy to me. You can always read flattened string, the default and then un-flatten separately into any data type.
Thanks,
-Gabe