AngryRobot

Use ArySearch to find active BOOLs in an array.

2 posts in this topic

I just stumbled onto this today, and I wanted to throw this out there in case someone else finds it useful.  You can use the ArySearch function to determine if there are any active elements in a BOOL array by setting the Key to P_On (or any other active BOOL variable).

I've been using a union of an LWORD and an array of 64 BOOL for faults/alarms and looking at the value of the union to be <> to 0 to indicate an alarm is active.  Well, I have a machine that is getting close to going past 64 alarms; so I set out to determine if there was anyway I could use a larger array.Do

Note though that this only works if you need to know if an element is active, or how many elements are active; it won't translate to a BCD value the way a union will. 

Share this post


Link to post
Share on other sites

Have a look at BitCnt. It does exactly as you describe and will only do up to an LWORD but may be more concise even if you have to use two of them.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now