If syntax

    Jul 08 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)
    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.

    • Jul 08 2009 | 6:37 am
      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 :
      if you really want to do that in a single object, you could use expr :
      However you can see that the same test is done twice, so that this is not so efficient. Ch.
    • Jul 08 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.
    • Jul 08 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
    • Jul 08 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?
    • Jul 08 2009 | 6:04 pm
      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.
    • Jul 08 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.
    • Jul 08 2009 | 6:54 pm
      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.
    • Jul 08 2009 | 8:29 pm
      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!
    • Jul 08 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!
    • Jul 08 2009 | 9:04 pm
      i will!
      Thanks again.
    • Jul 08 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
    • Jul 08 2009 | 10:39 pm
      Try [zl compare] which can match strings and lists.
    • Jul 09 2009 | 9:50 am
      thanks. I will try it.But can you give me the syntax.
    • Jul 09 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.