LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Store boolean array as text file

Solved!
Go to solution

Hi there

 

I'm having some trouble storinge a 25x25 2D array of booleans in a text file.

First I make the 2D array a 1D array, and then I change it to a number, but here something already goes wrong, not the full number is stored, presumably because the array is this big?

 

Any help will be much appreciated!

0 Kudos
Message 1 of 8
(4,782 Views)

Actually you're writing and reading binary files. Do you want to read the file as text in an external viewer? If not, just wire the boolean array to the Write Binary File data input. When you read it with Read Binary File, wire a boolean array constant to the data type input. Be aware that the 2D boolean array will be embedded in a cluster.

0 Kudos
Message 2 of 8
(4,777 Views)

Oh neat, I wasn't aware that that could be done. I tried linking it directly when i was writing to a text file normally, but that only accepted a string ofcourse, didn't try that wit binary... But how do I read the file then? I can't connect the read binary to an array directly..

0 Kudos
Message 3 of 8
(4,772 Views)

The output of the Read Binary file will be a cluster with your 2D boolean array inside.

0 Kudos
Message 4 of 8
(4,767 Views)
Solution
Accepted by jdepypere

Hi

 

to the Read Binary File function, there is an input called data type on the top. it is by default shown as a string input. wire a 2D boolean constant to that input. you can then read the boolean data from the file

 

if the count is 1, you get a boolean array at the output. if the coutn is -1, you will get an array of arrays.

Regards
Freelance_LV
TestAutomation Consultant
0 Kudos
Message 5 of 8
(4,766 Views)

I've been stuck on this for such a long time, and it's such an easy solution! I was trying all kinds of conversions, works nice now! Thanks again!

0 Kudos
Message 6 of 8
(4,762 Views)

oh good that you solved it!

 

i was meanwhile putting in place a vi that will show you the concept. good

Regards
Freelance_LV
TestAutomation Consultant
0 Kudos
Message 7 of 8
(4,760 Views)

You can also convert the 2D boolean array into 1D array of numbers and save to text file and then read back to load the original 2D Boolean array

-----

The best solution is the one you find it by yourself
0 Kudos
Message 8 of 8
(4,744 Views)