LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing to binary file

Hello Community!

 

I have an array of strings that needs to be written to a binary file. However, I have to keep the format of the file. That being 81 bytes per string to an amount of 40 strings in total. If the string array is smaller they need to be filled with unsigned bytes. Any ideas? Thank you very much in advance for the answer.

0 Kudos
Message 1 of 4
(1,301 Views)

How about...

 

Start with a string constant of 81 bytes containing the "fill" you need. Then use "Replace Substring" to insert your text into the string overwriting the first part and there you go!

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 4
(1,275 Views)

Pad your strings prior to the binary write.  You could combine your padding with limiting (to a maximum of 40) the amount of elements taken from the array.

 

Pad String.PNG

Message 3 of 4
(1,272 Views)

Second thought.  Format Into String is a poor choice, go for Replace Substring as Ben suggested, it gives you flexibility to define your padding character.

0 Kudos
Message 4 of 4
(1,254 Views)