cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Writing a string to binary file

Solved!
Go to solution

Writing a string to binary file

Hello Community

 

I am trying to write to a binary file that is read with Delphi as well as with LabView. While writing strings in the binary file Delphi uses 1 byte at the beginning for the string length and then writes the string. LabView does it differently though. Any Ideas of how can I write a byte array of a string replicating the Delphi format?

 

Thanks in advance

0 Kudos
Message 1 of 5
(210 Views)
Solution
Accepted by topic author AnaZerpa
09-11-2017 04:37 AM

Re: Writing a string to binary file

Hi Ana,

 

switch off the array/string size when writing the string to your binary file (it's an input parameter of the WriteBinaryFile function)!

Then write your own string length indication byte in front of the string (or prepend the length byte to the string data)…

Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2017 on Win7+cRIO
Kudos are welcome Smiley Wink

Message 2 of 5
(196 Views)

Re: Writing a string to binary file

HI,

You can simply everytime write at fisrt time an octet into binary file, before to write your data(String).

This obligate you to use fonction write to Binary file two time successively.

 

0 Kudos
Message 3 of 5
(186 Views)
Highlighted

Re: Writing a string to binary file

I am in the boat of prepending the length byte to your data before writing to the file.


There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines

The discussions from the Advanced User Track is not over. Join in the conversation: 2016 Advanced Users Track
Message 4 of 5
(175 Views)

Re: Writing a string to binary file

So how does Delphi handle strings longer than 255 bytes?

/Y

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 5
(152 Views)