LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to write a fixed character array to a binary file?

Hi all,

 

Is there a way to write a fixed size character array to a binary file?  I notice that when I try to create an array of unsigned bytes labview prepends the array with a pascal type length in front of the array.  Any way to keep this from happening?

0 Kudos
Message 1 of 8
(3,757 Views)
Open up the context help for Write to Binary File.  You'll see it has a value you can wire into the top that will do what you want to do.  Wire a False constant to Prepend array or string size.  The default is True.
0 Kudos
Message 2 of 8
(3,755 Views)
Go to help in the toolbar, then go to find examples and do a search for binary file. If I rember correct. In the early version(s) of labview 8 it was a small flaw in the write To Binary File VI. The "prepend array or string size?" input was marked as defualt false. But the correct is default true.


Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 3 of 8
(3,748 Views)
Just noticed that it only works for pure array inputs, clusters always prepend the array size ... but your suggestions are exactly what I need, I just need to write out the binary file in parts rather than try to cluster them first.  Thanks for the info!
0 Kudos
Message 4 of 8
(3,738 Views)

You hadn't mentioned anything about clusters in your message.  I imagine that clusters written out to a binary file will always have some additional info.  Since it is a more complicated datatype that can take on an infinite number of datastructure variations.

 

And to quote from the detailed help for the Write to Binary File VI  "Arrays and strings in hierarchical data types such as clusters always include size information."

0 Kudos
Message 5 of 8
(3,726 Views)

Ravens Fan wrote:

You hadn't mentioned anything about clusters in your message.  I imagine that clusters written out to a binary file will always have some additional info.  Since it is a more complicated datatype that can take on an infinite number of datastructure variations.

 

And to quote from the detailed help for the Write to Binary File VI  "Arrays and strings in hierarchical data types such as clusters always include size information."


 

Yes I agree. Please tell us exact what kind of structure you want to write file. It is no problem to write clusters or pure arrays to a binary file. But the methods used differ some.


Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 6 of 8
(3,700 Views)
The data I want to write is based on a C data structure.  It is a mixture of int 32, int 16, an int 16 array, and ascii strings.  I wired up the data to a cluster and for the most part got exactly what I needed.  It was just the extra bytes I saw in front of the array and the strings.  I have several options, I can modify my C data structure to have spare elements to account for the LabView padding, or I can try to use the prepend not true for arrays when I write the binary file out.  I think that I understand what I have to do in either case and report my progress when I have it working.  Thanks all again.
0 Kudos
Message 7 of 8
(3,690 Views)

Can you post some code. If you want to write a C struct that will be read by a non Labview application. You must consider problems with different Endian format. Also a C struct and a Labview cluster is not the same. The items in a C struct will always have the same size. This is not true for the items in a Labview cluster.



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 8 of 8
(3,684 Views)