LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving cluster as binary data

Solved!
Go to solution

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.

0 Kudos
Message 1 of 6
(3,042 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 6
(3,039 Views)

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?

0 Kudos
Message 3 of 6
(3,028 Views)
Solution
Accepted by topic author BowenM

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 6
(3,019 Views)

Smiley Sad

0 Kudos
Message 5 of 6
(3,014 Views)

@BowenM wrote:

Smiley Sad


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.  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 6
(3,008 Views)