Forums > MaxMSP

'if' object

November 11, 2010 | 10:50 am

the reference says that the ‘if’ object also accepts symbols but I didn’t succeed in using it.
i tried:

if $s1 == $s2 then 1 else 0 —-doesn’t work
if $s1 == hello then bang —-doesn’t work
if $s1 == ‘hello’ then bang —-doesn’t work

i couldn’t find any examples of the ‘if’ object using a symbol.
could anybody help me please and send some examples or tell me where my mistake is?

thanx
Cheers
Peer


November 11, 2010 | 11:29 am

It does also not work with double quotes…


November 11, 2010 | 11:41 am

so is it a bug?


November 11, 2010 | 11:51 am

A bug, or the documentation department already included functionality that has not yet been realized. I tried a few things, but nothing works and there are many complaints.

_
johan


November 11, 2010 | 12:05 pm

ok…thanx guys….I’ll find another solution ;-)


November 11, 2010 | 1:33 pm

Its not a bug.

Check the if reference page and you’ll notice (at the bottom) that operands like == are used to compare two numbers. Not symbols or lists; that’s where your error comes from when trying a symbol comparison.

Also check if’s message list: In left inlet: The word symbol, followed by a symbol (a word), will be stored in place of the $s argument.

Proof of concept follows below; when the number field is larger than 5 the symbol will be passed, otherwise a bang is send out.

So what exactly are you trying to compare? Two messages or so ("dave" and "mike" for example) ? Because then you might be better of using either the zl or the regexp object.

– Pasted Max Patch, click to expand. –

November 11, 2010 | 2:25 pm

I consider "if" an obsolete object in most cases (not all). Its only there for those who are stuck in lines of code coding/thinking…;-)
Check out "zl compare"…

Stefan


November 11, 2010 | 5:07 pm

hello,
maybe you forget "set"

if $s1 == $s2 then set 1 else set 0

I never use whith s just whith i but i thing it’s the same
P


November 12, 2010 | 1:55 am

arent symbols just a pointer to a table object.


November 12, 2010 | 10:35 am

You’re right Roman, it’s like this in expr since years:

– Pasted Max Patch, click to expand. –

November 12, 2010 | 11:19 am

The help file should include your example, Patrick !


November 12, 2010 | 2:12 pm

Roald,

not sure Roman would agree ;-)

I think the documentation is clear enough: if needs a conditional expression following expr‘s syntax, and expr’s documentation is quite explicit about this feature, even expr.maxhelp.

Bonne fin de journée,

p


November 12, 2010 | 3:13 pm

Patrick,

You’re right about the principle, but it wouldn’t be so difficult to integrate an example with symbols like yours in the help patch.

A bientôt.

R


November 12, 2010 | 4:05 pm

Ah. Basically the $s can only be the first variable: $s1. Another example then.

– Pasted Max Patch, click to expand. –

_
johan


November 12, 2010 | 4:14 pm

I added an example to the help file, but I would rather consider this feature deprecated.


November 12, 2010 | 4:27 pm

Hi ej,

why deprecated?

p


November 12, 2010 | 4:31 pm

@jvkr: you do realize that the reason your 2nd example ‘doesn’t work’ basically behaves as such because the message contents is wrong (wrong order) ?

Edit2: When you start the message with 1 the if object will consider this as a list and treat it as such (it won’t iterate over the separate parts). And because it doesn’t recognize the first part as a valid message it doesn’t respond to it.

Just saying to make sure people don’t get the idea that the construction can’t work when all you’re using is a message object.

…I should test more thoroughly before posting :-)


November 12, 2010 | 6:01 pm

it is deprecated because there are [110.sym_==] and [110.sym_!=].

[if] is getting lovely when you need a gate in an expression.

[if (((1*((random(1,100)))< (min(max($i2,0),100)))))==0 then $i1] for example
makes you one [110.probagate] with only one object.

-110


November 12, 2010 | 6:08 pm

btw, think about it, what should your friend the computer do when you give him this:

[if maria > sandra && sandra >= 0 then bang else out2 bang]

see why i cant work with symbols?

it would break the paradigm because it would be limited to == and !=.

-110


November 12, 2010 | 6:13 pm

@Patrick It’s just going to stay there as is. It’s unlikely that we will changing something in this area int the future.


November 12, 2010 | 6:14 pm

ok you might say [if maria > sandra then bang maria] seems right, but thats not what maxmsp is about.

-110


November 12, 2010 | 6:30 pm

if (all my wished Max features == true) then (status = happyness)



pid
November 12, 2010 | 8:26 pm

if roman bangs maria then sandra == unhappy


November 18, 2010 | 1:56 pm

in PHP 5 there is [===], which can compare type of 2 inputs as well as the
input itself – i have made a max patch which can do the same now ^^


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