Hum, I have had this issue with other things using $0, and it seems almost impossible while developing a patch to NOT save over a patch containing a $0 reference. There are some situations that I have learned not to do this, but that was only after several lost patches and data...
While it has been a while, I believe that those other issues also involved data structures.
While Pd is a great tool, it does have several things that will bite you, unless you heed Marshal Brodeen's advice, "It's easy, once you know the secret..."
Mike
On Mon, Dec 1, 2008 at 4:54 AM, Frank Barknecht fbar@footils.org wrote:
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__
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list