'if' object

Nov 11, 2010 at 10:50am

'if' object

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

#53262
Nov 11, 2010 at 11:29am

It does also not work with double quotes…

#191384
Nov 11, 2010 at 11:41am

so is it a bug?

#191385
Nov 11, 2010 at 11:51am

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

#191386
Nov 11, 2010 at 12:05pm

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

#191387
Nov 11, 2010 at 1:33pm

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. –
#191388
Nov 11, 2010 at 2:25pm

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

#191389
Nov 11, 2010 at 5:07pm

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

#191390
Nov 12, 2010 at 1:55am

arent symbols just a pointer to a table object.

#191391
Nov 12, 2010 at 10:35am

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

– Pasted Max Patch, click to expand. –
#191392
Nov 12, 2010 at 11:19am

The help file should include your example, Patrick !

#191393
Nov 12, 2010 at 2:12pm

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

#191394
Nov 12, 2010 at 3:13pm

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

#191395
Nov 12, 2010 at 4:05pm

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

– Pasted Max Patch, click to expand. –

_
johan

#191396
Nov 12, 2010 at 4:14pm

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

#191397
Nov 12, 2010 at 4:27pm

Hi ej,

why deprecated?

p

#191398
Nov 12, 2010 at 4:31pm

@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 :-)

#191399
Nov 12, 2010 at 6:01pm

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

#191400
Nov 12, 2010 at 6:08pm

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

#191401
Nov 12, 2010 at 6:13pm

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

#191402
Nov 12, 2010 at 6:14pm

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

-110

#191403
Nov 12, 2010 at 6:30pm

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

#191404
Nov 12, 2010 at 8:26pm

if roman bangs maria then sandra == unhappy

#191405
Nov 18, 2010 at 1:56pm

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 ^^

#191406

You must be logged in to reply to this topic.