07-23-2005 01:48 AM
07-23-2005 02:46 AM
@Kousy wrote:
...By using Search 1D array, I got the first TRUE match index from the array. But if I want to know all the occurrences of ON condition (TRUE from an array of booleans) from an array of switches.
07-24-2005 04:03 PM
I almost missed this message because you started a new thread.
In any case, the code altenbach posted will give you an array of the indexes that are set to true. So it sounds like that is at least part of what you want. The alarm you mention, is that one "master" alarm if any of them are true, or is it a separate alarm for each bit?
If it is one "master" alarm for all of them the logic menu has a function for ORing all the elements in a boolean array. Also when you say "alarm" what is the nature of this alarm? A dialog box? a flashing light (real or on the applications's front panel)? message in a status display?
The attached code shows one possible direction by adding onto altenbachs code the ability to accumulate a single error message based on the states of individual bits. (BTW: The other alternative that you might see would be to pass the array into a loop and use a case to append a message of the bit is true. The advantage of the one in the combined VI is that the loop only iterates for the number of true bits +1. Where as the other approach would have to look at all the bits one at a time.)