04-19-2017 09:46 AM
Hi I have an array of Boolean. I want to be able to turn some of them off but what I want to check for is if I set an element of I want to know the index of that element then I want to find the index of the element before it that is ON the one after it that is ON as well..
For example, If I turn array element 2 off and 1 is on and 12 is on. I want it to output that results first element off is 2, and then element ON before is 1 and after is 12. then Move on to the next element that is OFF.. So far that's what I have. I can't seem to move on past that. Please help me..see attached
04-19-2017 10:35 AM
This where I am leading so far.... I still cant manage to get what I want...
04-19-2017 10:40 AM
Something like this:
Please note to add a stop button with an appropriate event case to stop your VI is considered mandatory!
04-19-2017 10:55 AM - edited 04-19-2017 11:05 AM
Thanks for your reply. I am testing It but is there anything in the true case. Are the tunnels for case structure wired with default?
Update:
I tested with default wiring and it doesn't seem to work. Would you post the snippet of your code instead. I am afraid I might make mistake duplicating it....
Attached is the answer I get testing it
04-19-2017 01:01 PM
I found where I made a mistake in the delete array. It works fine now.
One more question, what if I want to count the number of consecutive ones before and after the one that is OFF.
for example if I turn off index 2 but 0 and 1 is on...it should give me the total number of 1 before 2 is 2... and same for the one after....
04-20-2017 02:44 AM
You can implement a recursive search for TRUE which stops as soon as
a) a FALSE is found as next/previous value
b) the array has no elements left to search
I am not sure how well this scales performance wise. Another option might be to treat the boolean array as integer number and use bit masking to look for criteria like you mentioned...