[PD] use of 0$-
Josh Steiner
josh at vitriolix.com
Wed Mar 2 01:27:32 CET 2005
pd/doc/1.manual/x2.htm
2.6.5. dollar signs
In message or object boxes, message arguments starting with a dollar
sign and a number (like "$1" or "$3-bazoo") are variables which are
substituted with values supplied as part of the environment the message
is passed in. In the case of message boxes, the environment consists of
the arguments of the "list" message (possibly extrapolated from "bang,"
"float," or other) that the message box is responding to. Thus, if a
message box gets "23 skidoo" and if it contains the text, "$2 until $1,"
out comes the message, "skidoo until 23."
Object boxes contain text which forms a message to be sent to Pd to
create and initialize the object. Here, $1, etc., are taken from the
context in which the patch was loaded. When the patch is a new document
or opened from a file the "$" variables are undefined. But if the patch
is an abstraction (see the next section) they are taken from the
abstractions' creation arguments.
Constructions such as "$1-x" are expanded by string concatenation. This
is the mechanism for making local variables. In particular, $0 in an
abstraction is a counter which is guaranteed to be unique to that
abstraction, so sends and receives with names like "$0-bear" can be used
as local send/receive pairs.
Note that the expansion of variables such as $0 and $1 only works at the
beginning of the symbol; so, for instance, "rats-$1" will not be
expanded. Occasionally you may want to have double or triple
substitutions; this can be done one stage at a time by nesting
abstractions (with each subpatch adding its own $-variable to the
beginning of a symbol and passing that on as argument to a further
abstraction.)
For example, if you want to get dog-food, dog-ears, and cat-food, for
example, have an abstraction "a1" that invokes an abstraction "a2"
twice, as "a2 $1-food" and "a2 $1-ears", and then in a third patch call
a1 twice, as "a1 cat" and "a1 dog". Inside the four "a2" copioes, $1
will evaluate to "dog-food", "cat-food", "dog-ears", and "cat-ears".
daniel wrote:
>hi list
>
>is there a place where I can read about the use of 0$- names?
>
>thanx in advance
>
>_______________________________________________
>PD-list at iem.at mailing list
>UNSUBSCRIBE and account-management -> http://iem.at/cgi-bin/mailman/listinfo/pd-list
>
>
--
________________________________________________________________
live experimental electronic music -- http://bluevitriol.com
independent u.s. drum'n'bass -- http://vitriolix.com
More information about the Pd-list
mailing list