Forums > MaxMSP

Help with if statements

June 9, 2011 | 7:16 pm

Hello,

I need to specify a range of x, y coordinates on a touch screen ie, if a touch event occurs between pixels x100 and x150 and y500 and 450 then something happens.

I have tried the following

if $i1 > 100 || $i1 < 150 then $i1

This seems to do nothing to the incoming integer. Is there a "between" type function for the if object?


June 9, 2011 | 7:34 pm

The "split" object does just that!


June 9, 2011 | 8:50 pm

Here’s one way

– Pasted Max Patch, click to expand. –

June 9, 2011 | 9:13 pm

The probelm is the logical distinction between ‘or’ and ‘and’; all integers are either >=100 OR < =150!! But only a specific range is both >100 AND <150. If you write [if Si1>100 && $i1<150 then $i1 else out2 $i1] you'll get the functionality of the [split] object

Brendan

[edit] just looked at Simon’s response, doh…..

ps, did I leave enough space between "and and ‘and’" ;)


June 9, 2011 | 9:49 pm

@n00b_meister – Har har do that space/syntax tango all the time, part of the fun… err maybe ;-)


June 10, 2011 | 8:57 am

Perfect, thanks people


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