[PD] $0 and Data Structure Templates
Frank Barknecht
fbar at footils.org
Mon Dec 1 11:54:34 CET 2008
Hallo,
Mike McGonagle hat gesagt: // Mike McGonagle wrote:
> I think this should be allowed, hell, even the use of other $
> arguments. It would be nice to be able to allow abstractions to create
> their own private data structures, or at least ones that could be
> named based on a creation argument.
All this *is* allowed. But Luke's problem is more general: If you use
$0, its value is only valid in a running patch. This not only affects
data structures, but everything, i.e. also qlist, textfile and so on.
If you write the value of $0 into textfile, you get something like
1023, which probably is not the same value $0 has when you reload the
file later in a different context.
It all boils down to the fact, that Pd only has global scoping and
that using $0 is just a limited workaround, but not adding a real
local scope.
The only thing that could be considered local scope in Pd are direct
patch cord connections: They are as local as it gets.
So what I generally do if I use $0-structs is to not save the data
structure instances with "write pd-x" but traverse and parse them down
into [textfile] and use that for storing and reloading. I.e. with
[struct $0-a float x float y]
and a data subpatch [pd x], I'd use traverse pd-x, and write each
x,y-pair into [textfile]. Then to reload, I clear pd-x, and dump the
textfile's contents to an [append $0-a x y].
This acctually has the advantage, that I can prepare the textfile in a
text editor or so.
Ciao
--
Frank Barknecht Do You RjDj.me? _ ______footils.org__
More information about the Pd-list
mailing list