detect when in range

Apr 16, 2006 at 10:19pm

detect when in range

i need to see wether a number is within a certain range, is there a way of attaching an AND to the ‘if’ object?

for example

if $1 < 1 AND > 1 …

#25459
Apr 16, 2006 at 10:32pm

Have a look at the logic ops like || and &&. These are common
programming operations. || means logical or and && means logical and.
Most expression objects will support these operations as well.

wes

#74964
Apr 16, 2006 at 10:36pm

thanks for that.

#74965
Apr 16, 2006 at 11:14pm

cool, i have worked out the syntax vaguely, how can i get a if object to output a bang?

#74966
Apr 16, 2006 at 11:19pm

here is the patch

max v2;
#N vpatcher 30 89 630 489;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P message 60 83 39 196617 set $1;
#P flonum 179 163 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P button 151 166 15 0;
#P newex 164 111 134 196617 if $i1* $i1 < 9 then set $i1;
#P flonum 174 60 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 8;
#P comment 334 68 100 196617 trying to assess if the input is between _3 and 3 , which the equation should do , and then output a bang , but i cant get it to output anything!!!;
#P connect 1 0 5 0;
#P connect 2 0 3 0;
#P connect 5 0 2 0;
#P connect 2 0 4 0;
#P pop;

#74967
Apr 16, 2006 at 11:23pm

sel 1 will output a bang if the input is 1

trigger b will always output a bang

depends on what you want.

wes

#74968
Apr 16, 2006 at 11:31pm

Here’s the patch below. Some friendly advice which is probably too
late for you now…read the manual and do the tutorials. Your patch
showed some serious misunderstandings of max.

#P button 211 226 15 0;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 224 171 124 196617 if $f1* $f1 < 9 then bang;
#P flonum 234 120 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 8;
#P comment 394 128 100 196617 trying to assess if the input is between
_3 and 3 , which the equation should do , and then output a bang ,
but i cant get it to output anything!!!;
#P connect 2 0 3 0;
#P connect 1 0 2 0;
#P window clipboard copycount 4;

#74969
Apr 16, 2006 at 11:31pm

could you look at the patcher,as it is not outputting anything at all

cheers

#74970
Apr 16, 2006 at 11:49pm

cant get that patcher to load, it just comes back up as text. isnt a patcher as text supposed to end with a ‘pop’ message?

“read the manual and do the tutorials. Your patch
showed some serious misunderstandings of max.” —i know. basically, i started with max about a year ago, then got quite heavily into flash.

unfortunatly, my memory isnt as good as i had hoped, but i am on a tight deadline for my degree (music technology) and my project must be in max (well, or PD, but we wont go there!!)

so i am relying on you peoples kind hearts and my own intensive ‘on the job’ research’ to get through

for the record, when you say serious misunderstandings, what do you mean?

again, thank you very much for your patience. for the record i am very much enjoying my learning, and when i can i will return the goodwill by participating on this forum in a helping capacity

cheers

#74971
Apr 16, 2006 at 11:53pm

I sent you a version that does what you want. See my last email.

wes

#74972
Apr 16, 2006 at 11:59pm

Ok,
you can just copy the text using command+C (apple + c on mac) and past
using command+v into a patcher. All of the objects should appear and
work.

> for the record, when you say serious misunderstandings, what do you mean?
>

You were using the set message to do things that you can’t use the set
message to do. Also, the fact that bang is a message and can just be
written as text for output from the if object.

wes

#74973
Apr 17, 2006 at 12:00am

emailed me direct? or PM the forum? i havent recieved any emails from you!

psc.recordings@gmail.com

#74974
Apr 17, 2006 at 12:13am

thanks for all you help!!

got it now

i’d like to say thats the last simple question i will have, but it wont be, so i wont!!

again

cheers

John

#74975
Apr 17, 2006 at 12:19am

Remember the one that you couldn’t get to load?? Try that one using
the instructions for copying and pasting. If you want to see it in
the forum, go here:
http://www.cycling74.com/forums/index.php?t=msg&th=19379&sta rt=0&rid=0&S=9dfa076a35fe24529ead0ab137c5878f

#74976
Apr 17, 2006 at 12:26am

yeah, got it

i never realised you could copy text direct into a patcher

for the record, is there a way to extract text from a patcher also?

my current method is to re-open the patcher as text and then copy and paste it

#74977
Apr 17, 2006 at 12:36am

also

in the help file for ‘if’ they use the syntax $i1, whereas in your solution you have used $f1, could you explain?

#74978
Apr 17, 2006 at 12:39am

same way highlight your objects and command+c.

#74979
Apr 17, 2006 at 12:51am

one is for floats one is for ints

#74980
Apr 17, 2006 at 11:26am

I think the split object may be what you’re looking for,
Cheers
Roger

#74981
Apr 17, 2006 at 2:52pm

Quote: 88mph wrote on Sun, 16 April 2006 16:19
—————————————————-
> i need to see wether a number is within a certain range, is there a way of attaching an AND to the ‘if’ object?
>
> for example
>
> if $1 < 1 AND > 1 …
—————————————————-

[if and if then else ... ] will not work, you
would have to use two [if]s in series.

what you want (topic) could be done by [split 22 33].

#74982
Apr 17, 2006 at 3:06pm

[if ($f1 >= 1) && ($f1 < = 2) then $f1 else out2 $f1]

is equivalent to

[split 1 2]

/*j

#P window setfont “Sans Serif” 9.;
#P flonum 418 187 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 456 187 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 418 159 48 196617 split 1 2;
#P flonum 286 81 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 128 187 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 358 188 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 128 159 240 196617 if ($f1 >= 1) && ($f1 < = 2) then $f1 else
out2 $f1;
#P connect 4 1 5 0;
#P connect 4 0 6 0;
#P connect 3 0 0 0;
#P connect 3 0 4 0;
#P connect 0 0 2 0;
#P connect 0 1 1 0;
#P window clipboard copycount 7;

#74983

You must be logged in to reply to this topic.