logic, testing multiple toggles

mharter's icon

Hello all.

I know there is an elegant way to do this, but I don't have any idea how to do it well, and my basic effort has failed. I'll bet there is an object that does it.

I have 7 toggles and I want to see if any one of them is on. If any are, set output to 1. If not, 0.

I tried this and it did not work:
if $i1 !=0 || $i2 !=0 || $i3 !=0 || $i4 !=0 || $i5 !=0 || $i6 !=0 || $i7 !=0 then 1 else 0

Thanks!
Matt

EasyMac's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Note that using (a[0] || a[1]) is saying,
if a[0] is not zero OR a[1] is not zero,
then the expression in parentheses is not zero

Also, giving jstrigger more than one expression in parentheses will give it more than one output, so you can have one jstrigger object interpreting complex combinations of quantities in more than one way to give you different analysis results fromt he same set.

pdelges's icon
Max Patch
Copy patch and select New From Clipboard in Max.

One way:

mharter's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Well, I have come up with a way to do it. This might not be the ideal solution, but it is simple and it works.

mharter's icon

Patrick, I didn't refresh before posting mine. It's great that we were thinking along the same track! Thanks so much folks for getting back on this one, very helpful.

Matt

seejayjames's icon

the oft-overlooked [decode] object might also interest you, especially if you plan to expand to other logic tests. great for things like solo/mute of multiple channels/toggles.