Pass message as a string to variable

Learn about building and using Max for Live devices.
Post Reply
Abuwabu
Posts: 44
Joined: Sun Apr 04, 2021 11:22 am

Pass message as a string to variable

Post by Abuwabu » Fri Apr 30, 2021 7:21 am

This is probably a bit of a newbie question here but how do you concatenate a message string so that the whole thing passes as a variable? For example in the patch here "Pan" and "id" are passed when clicking the message boxes; but I'd like "Pan A" and "id 20" to be the variable.

Patch:

Code: Select all

----------begin_max5_patcher---------- 521.3oc0VssSbCCD84juBKSeLfV6ba21Wn+.n1mqPUlDCXTVmHamvVg3euYFmTVZCYAT.Q0p0VywS7wmwyLI2EFPundmzRIel7CRPvcgAAHD.DLXGP2J1UTIrnaTs715KtgF4WxI24PXGwB+FwUkHZumGyFwZDthqU5q9oQV37TlFyNYUDgmmASIqPi9Qx4COitcqRWIcH2rG.qacinwCndH2uZj98lRiF9SNG739vPXH5YpysRqUbk7eD52DZxWmPlYypyz0nz3afo3r40IeRcxdRctn5yVXTMNh+ZtW.jJUm7jRknhbZmvnEakjOwlH.jjOS.fml6UNFGXaR9eJBL3H4TvkoEeZ1LhOY8l8Eed9G.w+TkwWqrnBjloTIe1bb7RMINElx3ulZY9r0x+YmrhtwEN5LXoGcrIzu.CG8cXTpK8HuQoHkxKEsUPVguPwmxLUrat9C4L99YHoejaPnJ6OYSU+udtjiUw62.j8FpObKoUJ8e+dM7XA3OVz15VSw3VM7BKxCGrRo0ozBmpVumOPyNvoIiquDhXGfHnwxhPD+PDwV.hfbfCF6VBhxXuSDMdQOeriu.Lkxd2XJ60wjuxRzzzIM1AuQR5abbSsALWGglJs2DKYoFYmZzelGRX56P35aOzZvSFcWVB0+r0kRitUgNGB5qmSrqD7oG8c48RAadEde3uADEV9cG -----------end_max5_patcher-----------

Abuwabu
Posts: 44
Joined: Sun Apr 04, 2021 11:22 am

Re: Pass message as a string to variable

Post by Abuwabu » Fri Apr 30, 2021 8:02 am

I found "tosymbol" which gets me most of the way there. The 'live.object' however is still not created using the whole symbol.

Patch:

Code: Select all

<pre><code>
----------begin_max5_patcher----------
550.3ocyVEsaaBCE8Y3qvxcOxhvNACz9R2Ovz1ySUSNfWqq.Cx1vRUU+2G1F
qtzQSBUrnjHYKe8Eetmqu2C7bX.bayNlBBtF7CPPvygAAVSFCAiqCf0zcEUT
k0Mnf86lsOBibaoY6zVy5F0S0aap7avKslGb8yXuMQWMWTwz1CBMZrkpKdfK
t+mRVg1EHn0Xzp3H.JljalSVaFwwqhA285Q0zoe6Y4Loepk4NHHDbmYmWBCM
CQmHEqYJE8d1+vwuQEfuLAAInIYH9PLLk3XHJyLulbYvPUgj2pAt63gnETw6
YqJ4zJvs8TofVy.eBMQJXS5rSAwDWJ.kjXmy2bglCFcDbqwkooeBY1zGmmsG
8SSOuz+85iefqrgKSNEO+.8xDa2KBiwlYB9HzD+tzLxR0wsUzd+FW8UyV6E3
.3Mlgq9tYjIJcV9OUlTx9EsqxTY3ZWbkMSk8luNQxnRnuJIgbYTk.Tl+SIDj
+gU6G9Yl2DeDJt9fUHQKsd.ubHXlhoYyW02+dsQUezxbYZeZXEW712jaiAi8
8ospoSV3OJ+kF30fnjozbAUyaD+sSoNmlL0NKjvGAISexxfD5XHQV.jvmRxK
eA.hfNAjvKQtK6LAjO+e3KoEAIz4BIeexbQx0ESaa6YR0n2VPFjodrQZVlEY
WxEtkV4Anj0y89iblnxAoG8ftSmzFYvcjMP2y1TxjhNt04PC+FvzpAZ91tgW
f5nhUpL7kv+.8+eyOA
-----------end_max5_patcher-----------
</code></pre>

chapelier fou
Posts: 6002
Joined: Mon May 15, 2006 12:15 pm

Re: Pass message as a string to variable

Post by chapelier fou » Fri Apr 30, 2021 12:26 pm

or just put the " " inside the message boxes.

Also look at [join] which makes lists out of anything.
and [sprintf] that let you format messages using variables.
MacBook Pro 13" Retina i7 2.8 GHz OS 10.13, L10.0.1, M4L.
MacStudio M1Max 32Go OS 12.3.1

chapelier fou
Posts: 6002
Joined: Mon May 15, 2006 12:15 pm

Re: Pass message as a string to variable

Post by chapelier fou » Fri Apr 30, 2021 12:28 pm

May I ask what your goal is ?
MacBook Pro 13" Retina i7 2.8 GHz OS 10.13, L10.0.1, M4L.
MacStudio M1Max 32Go OS 12.3.1

Abuwabu
Posts: 44
Joined: Sun Apr 04, 2021 11:22 am

Re: Pass message as a string to variable

Post by Abuwabu » Sat May 01, 2021 1:09 pm

Thanks Chapelier

The message boxes are being generated on the fly. Sprintf is a good solution.

Thanks for the pointers. Half the battle at the beginning is knowing what objects are available to you.

chapelier fou
Posts: 6002
Joined: Mon May 15, 2006 12:15 pm

Re: Pass message as a string to variable

Post by chapelier fou » Sat May 01, 2021 3:34 pm

Help files and their “see also” sections are the real MaxMSP manual, it’s good practice to always go check them.
MacBook Pro 13" Retina i7 2.8 GHz OS 10.13, L10.0.1, M4L.
MacStudio M1Max 32Go OS 12.3.1

Abuwabu
Posts: 44
Joined: Sun Apr 04, 2021 11:22 am

Re: Pass message as a string to variable

Post by Abuwabu » Sun May 02, 2021 8:43 am

Indeed. As a developer I am used to picking through API documentation. I didn't actually know there was a Max/MSP manual; I just went straight for the help files for each object. Pleased to see they are so well documented. So far my experience with Max/MSP has been really good.

chapelier fou
Posts: 6002
Joined: Mon May 15, 2006 12:15 pm

Re: Pass message as a string to variable

Post by chapelier fou » Sun May 02, 2021 11:27 am

There is no manual indeed.
MacBook Pro 13" Retina i7 2.8 GHz OS 10.13, L10.0.1, M4L.
MacStudio M1Max 32Go OS 12.3.1

Post Reply