[PD] storing parameters in message with sprintf

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

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]
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(


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


More information about the Pd-list mailing list