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.
11-12-2012 01:33 PM
Hi!
My data is mainly in string format.
Whenever I save DBL array in binary files – everything is ok (see file ‘UN Test Read write - DBL.vi’). This Labview 9 file writes binary file to root C:\ and then reads it.
When I try to load file with string array in it (file ’ UN Test Read write - STRING.vi’) – I get an error.
Is it possible to save sting arrays in binary files?
Solved! Go to Solution.
11-12-2012 01:43 PM
@Gurator wrote:
Hi!
My data is mainly in string format.
Whenever I save DBL array in binary files – everything is ok (see file ‘UN Test Read write - DBL.vi’). This Labview 9 file writes binary file to root C:\ and then reads it.
When I try to load file with string array in it (file ’ UN Test Read write - STRING.vi’) – I get an error.
Is it possible to save sting arrays in binary files?
You might be better served using the generic read file and write file VIs.
11-12-2012 02:09 PM
When you say you get an error, it helps if you tell what the error was. Number? Description?
I ran your VI and it worked okay for me.
11-12-2012 02:32 PM - edited 11-12-2012 02:34 PM
Instead of finding the file size and what not, just wire a -1 to the count on the read and all of the strings will be read.
There is also no need to set the file position to the start right after creating the file.
11-12-2012 02:32 PM
The problem is the fact that you do some fancy math, assuming that the elements are 8 bytes long. THis assumption cannot be made for arrays of strings.
If you write an array of string to a binary file, you simply need to read it again as array of strings. Here's a quick example. Your sequence structure is not needed, because execution order is fully determined by dataflow.
11-13-2012 10:04 AM
Hello!
Thank you for your quick solution. I considered casting all strings as ASCII arrays before you came and saved the day.
Strange thing though: feeding ]Read From Binary File' module with -1 works under Labview 9.0.1 on Windows XP Version 2002 SP3 but same file on same Labview version on Windows 7 SP1 generates Error 116 : Unflatten or byte stream read operation failed due to corrupt, unexpected or truncated data.
Hope nothing like this will happen during running compiled (on XP) executable.
11-13-2012 11:00 AM
Gurator wrote:I considered casting all strings as ASCII arrays before you came and saved the day.
I have no idea what you mean by that. ASCII is not a datatype.
Gurator wrote:Strange thing though: feeding ]Read From Binary File' module with -1 works under Labview 9.0.1 on Windows XP Version 2002 SP3 but same file on same Labview version on Windows 7 SP1 generates Error 116 : Unflatten or byte stream read operation failed due to corrupt, unexpected or truncated data.
Hope nothing like this will happen during running compiled (on XP) executable.
Are you absolutely sure the code is identical? If the file has been written using the litte endian option, you need to read it again using little endian, else the file will most likely be considered corrupt.
Also, under windows 7 you should not try to write to the root of the C: drive. There are better places.