LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

trouble using binary read/write

Solved!
Go to solution

Hi,

The binary read/write function is somehow not working properly in my application.

i a storing a 2D strign array in binary format. when the user closes the app, the app saves the table values to the Bin file.

N when the app starts, it reads the file and displays its content on the table.

The system works properly if the total size of the content is 3 bytes. but, if the content size exceeds 3 bytes, the program just returns NULL value at the start when i read the Bin file.

 

Procedure to Save:

Convert the 2D array into String by using "Flatten to String" fn and save it in into binary file.

 

Procedure to Read:

read binary file. convert the output string to 2D array using "Unflatten from string" .

 

 

I am attaching my code here. pls have a look at it and let me know the cause of the problem. 

 

 

Ritesh 

 

Message 1 of 5
(2,897 Views)

Hi there

 

Set the "prepend array or string size? (T)" parameter to TRUE.

 

Or use the "Spreadsheet String To Array"/"Array to Spreadsheet String" to convert the 2D string arrays to a human readable string.

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 2 of 5
(2,882 Views)

HI Chrisger,

I just tried  putting "prepend array or string size? (T)" parameter to TRUE, and still it didn't work.

 

i dont want to store it in a human readable form so i am going with binary file. is there any other work around?

 

 

Ritesh 

0 Kudos
Message 3 of 5
(2,873 Views)
Solution
Accepted by topic author LVCoder

I don't quite understand why you're flattening to a string a 2D array of strings. That's redundant. You seem to be also overriding the default byte order from big endian to little endian. Are you trying to save it in a format suitable for other programs on other platforms?

 

If not, all you need to do is this:

 Example_VI.png

Message 4 of 5
(2,855 Views)

smercurio_fc wrote:

I don't quite understand why you're flattening to a string a 2D array of strings. That's redundant. 


same here. Even i dont understand what i was thinking when i was writing that piece of code.
Anyways, thanks alot for correcting me. The code is just working fine now.
 
 
Thanks,
Ritesh 

 

0 Kudos
Message 5 of 5
(2,849 Views)