Forums > MaxMSP

If syntax

July 8, 2009 | 5:58 am

Hi all,
I was trying to resolve this problem searching in the forum posts, but i didn’t find anything.
Basically i want to write this sentence in the if object

if (in1+in2) < = in3 then out (in1+in3) else out in2

I’m trying with other alternatives, but its much more complicated in the patch I’m doing.

If anyone can help i would really appreciate it.



Ch
July 8, 2009 | 6:37 am

Hi,

I don’t think it is possible to do that in a single if object cause of the ($i1+$i3). You’ll probably have to do somthing like that :

– Pasted Max Patch, click to expand. –

if you really want to do that in a single object, you could use expr :

– Pasted Max Patch, click to expand. –

However you can see that the same test is done twice, so that this is not so efficient.
Ch.


July 8, 2009 | 8:57 am

The [if] object cannot do mathematical operations, however if would be possible with [expr] as Charles has shown in his post above. The method I would use is in the patch below and takes advantage of the fact that lists sent to most objects, in this case [+], act as though each element was sent to a successive inlet.

lh

– Pasted Max Patch, click to expand. –

July 8, 2009 | 3:00 pm

hi i am just a beginner with max and even not a very good programmer with max. I wish to use if/else for RFID tags.
But I believe that there might be a problem with the my if then else statement. Can you help me out


July 8, 2009 | 5:44 pm

Hi Rohit,

In general, you’ll get much more help if you post an example of what it is you are trying to accomplish–like the original poster above. Can you describe what you are trying to do?


July 8, 2009 | 6:04 pm

Hi!

Thanks for the answers, but I’m having problems opening the patches, maybe because I’m running max 4.5? I’ve done everything the "post patches to the forum post" says.


July 8, 2009 | 6:24 pm

Yeah, the gibberish-looking text above is in the new Max version 5 compressed text format that makes posting patches much smaller and easier. Unfortunately, that only works in Max 5.


July 8, 2009 | 6:54 pm

The patch I posted above looked like this:

[if ($f1+$f2)< =$f3 then $f1 $f3 else $f2 0]
|
[+ 0.]

With three [flonum] objects going into each inlet of a [pak 0. 0. 0.] before the [if] so that the output is triggered no matter which number box you change. If you have trouble recreating just say and I’ll post a screenshot.

lh


July 8, 2009 | 8:29 pm

It’s working great!
Thanks a lot, if you are around Buenos Aires i can send you a gift Very Happy
Thanks to all that replied to!

and now, back to work!


July 8, 2009 | 8:33 pm

Unfortunately not, but never mind, I’m glad it helped. You should definitely have a look at max 5, you can download a 30 day demo for free, it really is a big step up from working with 4.x!

lh


July 8, 2009 | 9:04 pm

i will!

Thanks again.


July 8, 2009 | 10:37 pm

hi
I am using RFID tags which give output in form of 013e218c..
something of this sort. I am trying to compare the values using if
like $s==……… then send 0 out2 else 1. something like this but it is giving syntax error. is there a method to type cast in max


July 8, 2009 | 10:39 pm

Try [zl compare] which can match strings and lists.

lh


July 9, 2009 | 9:50 am

thanks. I will try it.But can you give me the syntax.

Rohit


July 9, 2009 | 11:31 am

Have a look at the [zl compare] helpfile. It has two inlets and you send one list to each, if they are the same it outputs a 1 else a 0. You could then use [sel] or [gate] to trigger or route information depending on what you’re trying to do.

lh


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