'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
It does also not work with double quotes...
so is it a bug?
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
ok...thanx guys....I'll find another solution ;-)
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.
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
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
arent symbols just a pointer to a table object.
You're right Roman, it's like this in expr since years:
The help file should include your example, Patrick !
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
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
Ah. Basically the $s can only be the first variable: $s1. Another example then.
_
johan
I added an example to the help file, but I would rather consider this feature deprecated.
Hi ej,
why deprecated?
p
@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 :-)
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
@Patrick It's just going to stay there as is. It's unlikely that we will changing something in this area int the future.
ok you might say [if maria > sandra then bang maria] seems right, but thats not what maxmsp is about.
-110
if (all my wished Max features == true) then (status = happyness)
if roman bangs maria then sandra == unhappy
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 ^^