From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing a string to binary file

Solved!
Go to solution

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
(4,487 Views)
Solution
Accepted by AnaZerpa

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


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 5
(4,473 Views)

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
(4,463 Views)

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


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 5
(4,452 Views)

So how does Delphi handle strings longer than 255 bytes?

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 5
(4,429 Views)