Dear Hans and List:
Attached is a .zip of a possible solution. You can unzip and open "getcreationargstest.pd". In this patch, you'll find a [getcreationargstest_abs] abstraction with a bunch of float and symbol arguments. Open it up and have fun -- [getcreationargs] is the main abstraction -- there are two dependencies: 1) [digiter] which is an abstraction that iterates the digits of an integer, and 2) [log10] which is a base-ten log abstraction used in [digiter].
There are some downsides to it:
patch is the creation argument to [getcreationargs]. 3) it uses some rather arcane dynamic patching which might break in the future. 4) when it's used it sets the dirty flag.
I think this could at least be something like the right idea.... also I haven't tested on all platforms, and it's for 0.40 or greater.
Lemme know what you think!
Matt
Date: Sun, 23 Nov 2008 23:16:57 -0500 From: Hans-Christoph Steiner hans@eds.org Subject: Re: [PD] Testing for empty creation args? To: Jack jack@rybn.org Cc: pd-list@iem.at, IOhannes m zmoelnig zmoelnig@iem.at Message-ID: 28F600A9-504A-4289-82EC-91C996AD5E10@eds.org Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed
So I tried to use this within an abstraction, so it is reusable. Unforunately, the $1 gets initialized to 0 before it is sent to the abstraction, so this technique doesn't work as is.
Any ideas for how to make it work?
.hc
On Oct 24, 2008, at 11:24 AM, Jack wrote:
This a very nice method, thanx. But there is something strange in this abstraction according to the help page about [list]. I can read [list] short for [list append] but this is not true. In this abstraction if you replace [list append] by [list] and you enter a 'symbol' as argument, you have this error : list $1 ... couldn't create This is just a remark. ++
Jack
Le 14 oct. 08 ? 13:56, IOhannes m zmoelnig a ?crit :
Frank Barknecht wrote:
Hallo, Bill Gribble hat gesagt: // Bill Gribble wrote:
I am doing something like this:
|loadbang| | |symbol $1| | |readfile $1 cr, rewind( | |textfile|
There's also an interface to set the filename later.
Use this instead: [list append $1] | [select 0] |
[nofile( [s $0-FILENAME] | [s $0-FILENAME]since this does not differentiate between no args and "0", i prefer the attached version (too complicated for ascii art)
fmgasdr IOhannes
Ciao
#N canvas 351 18 450 490 10; #X obj 187 246 list append $1; #X msg 138 131 bang; #X obj 134 202 select s; #X obj 134 152 t b b; #X obj 242 179 makefilename $%d-test; #X obj 134 179 symbol $1-test; #X msg 242 159 1; #X obj 187 224 t b; #X obj 8 292 t b; #X text 15 312 no arg given; #X text 217 225 this is $1; #X obj 8 332 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X obj 187 279 print arg1; #X connect 0 0 12 0; #X connect 1 0 3 0; #X connect 2 0 8 0; #X connect 2 1 7 0; #X connect 3 0 5 0; #X connect 3 1 6 0; #X connect 4 0 2 1; #X connect 5 0 2 0; #X connect 6 0 4 0; #X connect 7 0 0 0; #X connect 8 0 11 0; _______________________________________________ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/ listinfo/pd-list
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/ listinfo/pd-list
Another downside, probably the most annoying, is that some of the dynamic patching needs to make the helper subpatch visible for a very short amount of time -- but it can show up... probably there's a way around that.
Matt
On Tue, Nov 25, 2008 at 6:49 PM, Matt Barber brbrofsvl@gmail.com wrote:
Dear Hans and List:
Attached is a .zip of a possible solution. You can unzip and open "getcreationargstest.pd". In this patch, you'll find a [getcreationargstest_abs] abstraction with a bunch of float and symbol arguments. Open it up and have fun -- [getcreationargs] is the main abstraction -- there are two dependencies: 1) [digiter] which is an abstraction that iterates the digits of an integer, and 2) [log10] which is a base-ten log abstraction used in [digiter].
There are some downsides to it:
- it requires helper abstractions.
- it requires a helper subpatch in the parent (the name of this
patch is the creation argument to [getcreationargs]. 3) it uses some rather arcane dynamic patching which might break in the future. 4) when it's used it sets the dirty flag.
I think this could at least be something like the right idea.... also I haven't tested on all platforms, and it's for 0.40 or greater.
Lemme know what you think!
Matt
Date: Sun, 23 Nov 2008 23:16:57 -0500 From: Hans-Christoph Steiner hans@eds.org Subject: Re: [PD] Testing for empty creation args? To: Jack jack@rybn.org Cc: pd-list@iem.at, IOhannes m zmoelnig zmoelnig@iem.at Message-ID: 28F600A9-504A-4289-82EC-91C996AD5E10@eds.org Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed
So I tried to use this within an abstraction, so it is reusable. Unforunately, the $1 gets initialized to 0 before it is sent to the abstraction, so this technique doesn't work as is.
Any ideas for how to make it work?
.hc
On Oct 24, 2008, at 11:24 AM, Jack wrote:
This a very nice method, thanx. But there is something strange in this abstraction according to the help page about [list]. I can read [list] short for [list append] but this is not true. In this abstraction if you replace [list append] by [list] and you enter a 'symbol' as argument, you have this error : list $1 ... couldn't create This is just a remark. ++
Jack
Le 14 oct. 08 ? 13:56, IOhannes m zmoelnig a ?crit :
Frank Barknecht wrote:
Hallo, Bill Gribble hat gesagt: // Bill Gribble wrote:
I am doing something like this:
|loadbang| | |symbol $1| | |readfile $1 cr, rewind( | |textfile|
There's also an interface to set the filename later.
Use this instead: [list append $1] | [select 0] |
[nofile( [s $0-FILENAME] | [s $0-FILENAME]since this does not differentiate between no args and "0", i prefer the attached version (too complicated for ascii art)
fmgasdr IOhannes
Ciao
#N canvas 351 18 450 490 10; #X obj 187 246 list append $1; #X msg 138 131 bang; #X obj 134 202 select s; #X obj 134 152 t b b; #X obj 242 179 makefilename $%d-test; #X obj 134 179 symbol $1-test; #X msg 242 159 1; #X obj 187 224 t b; #X obj 8 292 t b; #X text 15 312 no arg given; #X text 217 225 this is $1; #X obj 8 332 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X obj 187 279 print arg1; #X connect 0 0 12 0; #X connect 1 0 3 0; #X connect 2 0 8 0; #X connect 2 1 7 0; #X connect 3 0 5 0; #X connect 3 1 6 0; #X connect 4 0 2 1; #X connect 5 0 2 0; #X connect 6 0 4 0; #X connect 7 0 0 0; #X connect 8 0 11 0; _______________________________________________ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/ listinfo/pd-list
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/ listinfo/pd-list
Actually, after using it for a while the worst downside is that it uses so many "key" events in the dynamic patching, which trigger [key] elsewhere in the patch.
It seems to me that getting the creation args of an abstraction with a float or testing to see if a creation argument exists is a vanilla-level problem that would be best solved with a new object in vanilla.
At some point it might be worthwhile to enumerate the features of Pd's objectclass API that can't be emulated well with abstractions (for instance, a left inlet that can take both signals and messages).
Matt
On Tue, Nov 25, 2008 at 7:31 PM, Matt Barber brbrofsvl@gmail.com wrote:
Another downside, probably the most annoying, is that some of the dynamic patching needs to make the helper subpatch visible for a very short amount of time -- but it can show up... probably there's a way around that.
Matt
On Tue, Nov 25, 2008 at 6:49 PM, Matt Barber brbrofsvl@gmail.com wrote:
Dear Hans and List:
Attached is a .zip of a possible solution. You can unzip and open "getcreationargstest.pd". In this patch, you'll find a [getcreationargstest_abs] abstraction with a bunch of float and symbol arguments. Open it up and have fun -- [getcreationargs] is the main abstraction -- there are two dependencies: 1) [digiter] which is an abstraction that iterates the digits of an integer, and 2) [log10] which is a base-ten log abstraction used in [digiter].
There are some downsides to it:
- it requires helper abstractions.
- it requires a helper subpatch in the parent (the name of this
patch is the creation argument to [getcreationargs]. 3) it uses some rather arcane dynamic patching which might break in the future. 4) when it's used it sets the dirty flag.
I think this could at least be something like the right idea.... also I haven't tested on all platforms, and it's for 0.40 or greater.
Lemme know what you think!
Matt
Matt Barber wrote:
Actually, after using it for a while the worst downside is that it uses so many "key" events in the dynamic patching, which trigger [key] elsewhere in the patch.
since you approach required both an abstraction and a specially named subpatch on the parent, why don't you just copy the code needed directly into your abstraction? no dynamic patching required whatsoever :-)
fgamdr IOhannes
(Attached is a better solution than my previous one -- read below for details) =o)
On Fri, Nov 28, 2008 at 7:23 AM, IOhannes m zmoelnig zmoelnig@iem.at wrote:
Matt Barber wrote:
Actually, after using it for a while the worst downside is that it uses so many "key" events in the dynamic patching, which trigger [key] elsewhere in the patch.
since you approach required both an abstraction and a specially named subpatch on the parent, why don't you just copy the code needed directly into your abstraction? no dynamic patching required whatsoever :-)
fgamdr IOhannes
Right,
But the idea is that it might be nice to make an abstraction which outputs its parent's creation arguments at the main outlet when it receives a float. If the float is out of range (e.g. if you're looking for the 5th argument in a 3-argument list), it should output a bang at another outlet. With an abstraction, you can quickly iterate over the creation args (useful if you want to set default values in the parent, say), and it scales to any number of creation arguments -- but the price is one extra subpatch on the parent.
The problem I had, which I think was HC's original problem when he tried to make it an abstraction, was that any dollar argument that's out of range becomes a 0 (zero) rather than "no argument" when it's passed to a child abstraction, so it doesn't seem to work to put the code for your [makefilename] solution in an abstraction.
My solution dynamically instantiates your original solution directly onto the parent (in the helper subpatch on the parent). I had been having trouble getting dollarsigns to dynamically patch. My brute-force method was to dynamically "type" the dollarsign arguments in, which can be done only when the subpatch is visible, sets the dirty flag, and triggers [key]... but I found out what I was doing wrong, and have attached a much better solution whose only downside is the helper subpatch on the parent - it no longer needs the helper abstractions and doesn't have any key or mouse events.
Best,
Matt