If/Then vs. Logic
Hello everyone,
From what I understand, "if" and "expr", while easier to comprehend for a novice programmer, are an inefficient way to check and compare values. However, most of Max's logic objects are limited to only comparing two numbers.
For example, I have the following statement, "if $i1 + $i2 + $i3 + $i4 + $i5 + $i6 + $i7 + $i8 + $i9 == 0 then bang". All I really want to do is check 9 toggles, bang if they're all off. It seems like I should be able to use && for something like this, but it will only compare two numbers. I even thought about using coll or some sort of list operation, but that seems like it would be unnecessarily complicated.
Anyone know the best (most efficient) way to perform operations like this?
Thanks in advance for your help!
In this particular situation another logic is possible, putting the values of all the toggles in a list and summing the result. If you have 9 times a 1 (toggle on) than the sum is 9. This you can feed to a selecting procedure...
Rock and roll! I had a feeling that some sort of list would be the way to go. I was actually checking to see if the toggles were all off, so changing sel 9 to sel 0 returns the bang I'm looking for.
Cheers! :)
You might also want to look into [vexpr], the list-savvy version of [expr].
to find out if the sum of al is zero, multiplying them using [accum] should be enough.