[PD] storing parameters in message with sprintf

IOhannes m zmoelnig zmoelnig at iem.at
Wed Oct 16 10:01:32 CEST 2013


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 2013-10-15 22:05, Olivier Baudry wrote:
> 
> Dear all,
> 
> Is it possible to write message after sprintf set;  function you
> can see below detail of patcher :

most likiely you are trying to create a couple of  messages like
"/harmonizer/hamp 12.1 10".
but [sprintf] (btw, there is no [sprintf] object built-into Pd (nor is
it needed most of the time)) will not create messages, it will create
a symbol. it will even create symbols containing spaces, which are a
bit tricky as they look exactly like ordinary atom-lists (messages,
objects with args) that use space as delimiter, but unfortunately are
something completely different.
it seems that what you really want to do is to build (and send) a set
of parameterized messages, which can be done using $arg expansion.

e.g. the folowing will send a message "2" to the receiver "foo", a
message "2" to the receiver "bar" and a message "10" to the receiver
"baz" whenever you click on [list 2 10(.

[list 2 10(
|
[; foo $1; bar $1; baz $2(

see the msg-help (right-click on the msgbox) for more info.

if you don't want to send those messages immediately but create a
msgbox with fixed values that you can copy around and click as an easy
preset system, you could do:

[list 2 10(
|
[set, add, add foo $1, add bar $1, add baz $2(
|
[ (

replace the [list 2 10( msgbox with a [pack] to make the values
changeable at runtime.



some other notes, you might find useful when patching:

subpatches (e.g. [pd foo]) do not evaluate the subpatches arguments.
e.g. if you have a patch containing a subpatch [pd listiter 2] and
within the subpatch yo have [zl iter $1], then the '$1' will not
(necessarily) be replaced by 'listiter' and even less by '2'; it will
be replaced by the argument you gove to the [foo] abstraction!

Pd doesn't have a built-in [prepend] object. there are a number of
libraries that provide imncompatible [prepend] objects, so it's better
not to use them. Pd has a built-in [list prepend] object (unless you
are using an old version of Pd) which will mostly do what you want. if
you want to get rid of the "list" selector, you can use [list trim]
thereafter.
however, if you only want to append a single value to fixed selector
(as indicated by [prepend /harmonizer/hdelay]) you can simply do $1
expansion in message boxes: [harmonizer/hdelay $1(


fgmasdr
IOhannes

PS: how did you manage to create objects at coordinates like "-3742
- -1745"??
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Icedove - http://www.enigmail.net/

iQIcBAEBCAAGBQJSXkfZAAoJELZQGcR/ejb4VxwP/0/0PKqLroJaxLdufbdd2jK6
coIaGWyjjIRtBnof80CfK7HrXEX55Z7tq/Wpky345Ddkul6yfaH+8B4zCHSoAb5/
ahRKjBRRXdxZIUUO5+aHUjU2NCB3IXlelUQFcqoQfSJY6t8neBnPJ6RqmWen7bQX
o1jLPG1bbqSnxYz0PQBwE6p9jzvgsYpS5G5J3q/ZEk0dB+1ISU51sZ8dCdm7LCQ5
/jwTYhLq7e/UjznSQtHwZ5FqQhwGlKKp2oYrU1pqUoE37jt2NAzRaiIb+VricT/D
75waZ5wlO6JV8uyEUmOionbLRf9Xo3hYp8FjN5JgJPD4BcTF56nmnC5oguhTMzvK
woo7oYZ3idtYOZ4rVSw7AEudYsyhYqoDmuqA+awo5crQ1PDmVx0qmu8dRRYExocL
RljTeNsINJmhqB19YA3FRc50zgsb5nOZ6Kyq0xSNio1TxDI5X93dhePL1f4AKG/h
f4wYsP2zq0SRSoF2QvVSMDkTg+9Xuv5bODYUSpn28fcMLvK35exkFbzr3qUMf/NT
7MHPHuGRBV7GnpHUWZutqpZRYNslV51CqbrEIY8NHuKZ5yJvU1siQ6BN28zmsVD6
5qMc2Hk3Wn2kf9vYFRFB2oaOSn6/9kQX0fT8aAYETzmz5mPE4el8ObVN3x/Ne+Ei
fXG7V1aEzhTxetskKf+V
=Ey02
-----END PGP SIGNATURE-----



More information about the Pd-list mailing list