if sentence

Nov 29, 2010 at 8:08am

if sentence

Hi forum,

I am new to max, so a simple question:

How do I make an if sentence that can set a toggle to 1 when the value is between 0 and 10?

I have tried to do it here – see the code below. I can’t get it to work …

– Pasted Max Patch, click to expand. –

Thanks for your help!

#53610
Nov 29, 2010 at 8:32am

using the [if] expression, I would say

if $1 <10 then out 2 1

and connect outlet 2 to your toggle;
look at the helpfile for [if] under ‘multiple conditions’ to get the syntax correct;

this will continuously give a 1 when input is <10, if you want it to happen only once look at [onebang]

#192768
Nov 29, 2010 at 11:26am

Two other approaches, using [split] and [expr].

_
johan

– Pasted Max Patch, click to expand. –
#192769
Nov 29, 2010 at 1:41pm

[expr $i1>=0 && $i1< =10]

#192770
Nov 29, 2010 at 6:45pm

At the risk of being known as the “benchmark guy” I’m happy to report that expr wins this race:

– Pasted Max Patch, click to expand. –
#192771
Nov 29, 2010 at 8:17pm

being the benchmark guy is important, it’s good to see how things compare under the hood.

#192772

You must be logged in to reply to this topic.