If syntax

agustin genoud's icon

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)

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's icon

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 :

Max Patch
Copy patch and select New From Clipboard in Max.

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

Max Patch
Copy patch and select New From Clipboard in Max.

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

Luke Hall's icon

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

Max Patch
Copy patch and select New From Clipboard in Max.

rohit28mohan's icon

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

bkshepard's icon

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?

agustin genoud's icon

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.

bkshepard's icon

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.

Luke Hall's icon

The patch I posted above looked like this:

[if ($f1+$f2)
|
[+ 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

agustin genoud's icon

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

and now, back to work!

Luke Hall's icon

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

agustin genoud's icon

i will!

Thanks again.

rohit28mohan's icon

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

Luke Hall's icon

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

lh

rohit28mohan's icon

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

Rohit

Luke Hall's icon

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