12-07-2012 04:46 AM
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!
Solved! Go to Solution.
12-07-2012 04:54 AM - edited 12-07-2012 05:03 AM
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.
12-07-2012 05:01 AM
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..
12-07-2012 05:03 AM
The output of the Read Binary file will be a cluster with your 2D boolean array inside.
12-07-2012 05:04 AM - edited 12-07-2012 05:05 AM
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.
12-07-2012 05:07 AM
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!
12-07-2012 05:11 AM
oh good that you solved it!
i was meanwhile putting in place a vi that will show you the concept. good
12-07-2012 06:38 AM
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