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.
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.
07-06-2009 03:43 AM
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
Solved! Go to Solution.
07-06-2009 06:39 AM
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.
07-06-2009 08:02 AM
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
07-06-2009 09:18 AM
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:
07-06-2009 09:29 AM
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