10-20-2014 10:13 AM
I have a cluster consisting of ~50 elements of various types that I need to save as binary data. I could obvoiusly do this with the "brute force" method of 50 different writes to the file, but that seems silly.
Is there an easier way to just dump it to disk as binary data? Saving it as a cluster seems to add extra characters.
In an all LV world, I would just save it as a variant but it has to be saved as raw binary in order to be read in by another program as a C structure.
Solved! Go to Solution.
10-20-2014 10:21 AM
The cluster does not add any extra bytes when saving it to a binary file. What you could be seeing is the strings and arrays having an extra I32 for the lengths.
10-20-2014 10:29 AM
So it is. The C struct is expecting exact array and string sizes, but it makes sense that LV needs to save that information with the file. Is there a way to make it not save that?
10-20-2014 10:34 AM
There is the nice boolean input to the Write Binary File for "prepend string/array size". Unfortunately, that boolean only applies to the top level data type that is being written. So anything inside of the cluster will still have those lengths prepended. Therefore, you will need to unbundle your data and write each peice individually.
10-20-2014 10:39 AM
10-20-2014 10:52 AM
@BowenM wrote:
Why the sad face? A whole bunch of stuff to unbundle? I feel for you. It's not as bad as it sounds, though. 🙂
Oh and FYI - the help file (detailed help) is actually helpful, unlike most help files you read. I think NI did a GREAT job on it and it's a great way to see what it does and what your options are. (The prepend array or string size? option is the first one mentioned.) I use it ALL the time. 🙂
The other thing that helps - at least when you are still trying to find your way around the palettes - is using the function search. The node names are highly descriptive and chances are you'll find what you need by typing some keywords. 🙂