the reference says that the ‘if’ object also accepts symbols but I didn’t succeed in using it.
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?
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.
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.
----------begin_max5_patcher---------- 451.3ocwUkraCBCD8LQp+CiP4XZDFJDROTo9cTEUwhSvUfMBaTSZT+2K1rjM QAx5EaomGFdyyuY71mFoo6yVi45vqvGfl11BDMElDQqFPSOwacPrGWEnNE+M y+K8IUmIvqEJbA3C9MvrbQLVH1jhKyttuGck9jpcXQcbKYTA0KQEk96YDu3l TPBUfE+rmQVMnz7DBsH0Jxf1Cs7OpfM2O6bxOpriLmZTim5IBhHzUelgCDkD zQdL7hqb0xVtZZL0.Vn9heeZjbuXaR+0o7DebV6BBgJNa8v8lKGHKCoFLGIW sMtF5QK9lzLkRLn5e1fpeiyn9MU1Aj8rqlevOWHXzNZP1YD1qZcFT0h5zjib pKmKtnRvbt2J7o2p7MI9rXHBGGyZNMlPwArbp3.W4IJwfaGZY5fYGBzfsCtp oC1yUdByaR2.YILlXBuA1fHBSgwbDfi4Xnb94USxP2IICY5VZ4bZ0sURck43 3mhToUdvQRImkmETW6UCDAicZPHlKHTOAongaWPE0Lf1ETDILDSOX.QBILkU LNphG+28auol7sqt41QAcO4FpKt49P3lSutReP5Ve31rGB0r5amvkQMIPw1e fbtP2B -----------end_max5_patcher-----------
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"…
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
arent symbols just a pointer to a table object.
You’re right Roman, it’s like this in expr since years:
----------begin_max5_patcher---------- 681.3oc6W90aaBCD.+Y3SgEZO1UYy+BoR8KwzzdoJJx.NIdBrivNqIqpe2m+ CzPHTVHIKsOLIDHNaeb2Oe24iWbc7R4aIBOvCfm.NNu353XDoE3T+tiWIdaV AVXllWFurjvjd2YGSR1JMx+d0NfbEWP.kDg.ujHdnYNrMk7MxBhznAXsTZtY c7ze9UzzlotfyjLbIwLzOHU4XFt8XB5uMig7uGtW6TVixQ0BWikYqnrkyqHY Rq6glFpVCHYh9NJBpe3itGBloWxqtt5a2chTfQdVY3GAgBNNW69.9ZBqe2G0 i6O4TbeqNj6VSr9imGX10gLASLjweRhAMPz+BzHwoEDvBNOEW0OY76gLQmEY n53SfWJlsbbPxeHHEowR8ijf8LpdMhU7mI4TIupMtsRZom3X8JCiLggAwFVG .8aqH7uH4yUtuZMywRYEMcizlj57FyUFdCMNfopuXYJIuUhVWKauX5RV2Y9F eRZDUofXWYLtjz74gFYlXjwFoTWn3nPEwtxTdwfwJ8kEEdgYQqqHBUkMrjxY s23ir60PyFOr91UKrBZx8PHyGYpI3.M8LS85.z+NxBtAEdFv4mlXyhpQvjqo y2MZ5a7R7HJIi9XICpNRvFVffvKBMCVRd.vzSE43OMEjCiCZWPN93BxcKlYc 344XI1pBcp7+uFykp4fAFDcNJczGfZ2ug1yO8smeFcAme1NAn0wmnO6Ge9NY 0zEfuHPOo1LlAd7Q8lhpubBylmCHEpNzY7L5xwbz5Ga+oMECirMll32a+olu lWAk08+YLZTK+PVJ3apxZr0l1vaENlSDRJyzMP6IEcvjVQyyIr1+VSIMeMWU uq1Hdm50WUaJ91ZRgmBlFmIEnNmKRsCGF1zpUyaWpwdJ1ppKH.51wOz0mecR Dbe08OfPpBo9 -----------end_max5_patcher-----------
The help file should include your example, Patrick !
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,
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.
Ah. Basically the $s can only be the first variable: $s1. Another example then.
----------begin_max5_patcher---------- 533.3oc2V0zaiBCD8L7qXDpR8R1Ha9HgTo9mXOrWVUUYvtIdavNB6nl1p9eu fMHxtoXH6VgR2KF4wFy687aFlW88BxjGXp.3F3mfm2q9ddlP0A7Zl6ETPNju knLaKHWVTvD5fY10zrCZSbpjoDWqgmjkOdS6p6H57Mbw56KY4Z6WIBglilAQ KpGwIlIgUivcMuCmZNOY1u9VXX6A8fTnEjBlYoevJoDAocMw9BtXKSavGtKn butMJ5niQwewbLX7bTcz278qGlMR9WvTJxZ1I7GCpmKxjaAJkNL8WXFSSLhP ZOrGc1rO7CYOtG12D1tS8y6XVHFD.28WHLB1SUn9Dcg+.bEGC2dKfA8Fl.TL AEtREBYDw5gUpUViRZrKiBN8SRpl.ix2kEDgCdiii6RPhW4xgfW9kxgzmh3N iAiR6zinv4INzijuT5Q1dsV5zJTQWSUxEsleGo.gmQ8PbeDwjS9Yl9WBC52a Ho8QxRmjL5rufQWdkD2Qdr8mEG.rCowVzaoQXVk3TXvmsvDcI67sLebFezEp w2cYsFFZc8wNYX7+CldSe.gm1G.dn9.rB0nZCHZ55Bv74C1xE+Y2yFFTG+2k HkbeYdqv11cGzwBJSo4BhlWkVzso59ZNZSa3TJSbLBK3zcRtP2.hdtvFKlp6 mXXLUUpo5NbxvTxEHlhFClBm16N7HvTzjBo3wnRn+AHUM4M+28IiksK -----------end_max5_patcher-----------
I added an example to the help file, but I would rather consider this feature deprecated.
@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 :-)
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.
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 !=.
@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.
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 ^^
Forums > MaxMSP