Help with if statements

Jun 9, 2011 at 7:16pm

Help with if statements


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?

Jun 9, 2011 at 7:34pm

The “split” object does just that!

Jun 9, 2011 at 8:50pm

Here’s one way

– Pasted Max Patch, click to expand. –
Jun 9, 2011 at 9:13pm

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


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

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

Jun 9, 2011 at 9:49pm

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

Jun 10, 2011 at 8:57am

Perfect, thanks people


You must be logged in to reply to this topic.