Forums > MaxMSP

Help expression IF


Apr 12 2009 | 8:42 am

Hi,

I dont know about if, what is wrong please?

if $i1 >= 9 then $i1-8 else $i1

Thanks

Prone

Apr 12 2009 | 9:10 am

I would go about this a little differently:

"if $i1 >= 9 then $i1 else out2 $i1"

Put a "- 8" object after the first outlet, and don’t after the second. Connect both outlets to the same place afterwards.

However, I doubt this will work recursively, if that’s what you want (for instance, 35 would only become 27, and it would probably stack overflow.) the Modulo operator might be more what you’re looking for?

Type "% 9" into an object box (no quotes, of course), and anything you pass through it will be remaindered to be between 0 and 8. In our previous example, 35 would become the number 8. "% 10" will go between 0 and 9.

Here’s a quick patch to illustrate that:

— Pasted Max Patch, click to expand. —
Apr 12 2009 | 12:24 pm

the -8 is what is wrong.

[if] is – unfortunatly – not [expr]!

Apr 12 2009 | 1:26 pm

thanks Smile

Viewing 4 posts - 1 through 4 (of 4 total)

Forums > MaxMSP