Re: [PD] Abstraction arguments: tell apart symbols from floats from no argument at all

2018-12-31 Thread Ingo Stock
Here is a solution by Jonathan Wilkes that fetches the complete list of
creation args including zeros.

Source: https://lists.puredata.info/pipermail/pd-list/2009-04/069941.html

On 22.12.18 19:52, Peter P. wrote:
> * hans w. koch  [2018-12-22 19:28]:
>> i have this vanilla abstraction based on a patch by johannes, which gives 1 
>> for argument present and 0 if absent
>> maybe thats for you?
> 
> Thanks Hans, this looks good and seems to be a similar way than the one
> proposed by Christof.
> 
> best, P
>>
>> best hans
> 
> 
> 
> ___
> Pd-list@lists.iem.at mailing list
> UNSUBSCRIBE and account-management -> 
> https://lists.puredata.info/listinfo/pd-list
> 
#N canvas 412 3 413 170 12;
#X obj 14 7 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#N canvas 0 0 562 568 arguments 1;
#X obj 39 112 f;
#X obj 39 137 + 1;
#X obj 39 162 t b a;
#X obj 39 462 t a;
#X obj 39 57 until;
#X obj 39 438 list prepend;
#X obj 10 527 outlet;
#X obj 39 7 inlet;
#X obj 39 32 t b b;
#X obj 39 363 list split 1;
#N canvas 368 169 216 100 \$0-test 0;
#X restore 39 308 pd \$0-test;
#X obj 76 253 s pd-\$0-test;
#X obj 39 338 r \$0-arg;
#X obj 76 187 list append \$0 $;
#X msg 122 338 symbol \$3\$1-t;
#X obj 85 388 sel s;
#X obj 85 413 s \$0-argv-end;
#X obj 88 32 s \$0-argv-reset;
#X obj 144 438 r \$0-argv-reset;
#X obj 89 57 r \$0-argv-end;
#X obj 39 278 s \$0-argv-b;
#X msg 76 212 clear \, obj 5 5 r \$2-argv-b \, obj 5 35 list append
\$3\$1 \$3\$1-t \, obj 5 65 s \$2-arg \, connect 0 0 1 0 \, connect
1 0 2 0;
#X obj 89 82 0;
#X obj 10 502 list;
#X connect 0 0 1 0;
#X connect 1 0 0 1;
#X connect 1 0 2 0;
#X connect 2 0 20 0;
#X connect 2 1 13 0;
#X connect 3 0 5 1;
#X connect 3 0 23 1;
#X connect 4 0 0 0;
#X connect 5 0 3 0;
#X connect 7 0 8 0;
#X connect 8 0 4 0;
#X connect 8 1 17 0;
#X connect 9 0 5 0;
#X connect 9 1 15 0;
#X connect 12 0 9 0;
#X connect 13 0 21 0;
#X connect 13 0 14 0;
#X connect 14 0 15 1;
#X connect 15 0 16 0;
#X connect 15 0 23 0;
#X connect 18 0 5 1;
#X connect 18 0 23 1;
#X connect 19 0 4 1;
#X connect 19 0 22 0;
#X connect 21 0 11 0;
#X connect 22 0 0 1;
#X connect 23 0 6 0;
#X restore 14 32 pd arguments;
#X obj 48 61 list length;
#X floatatom 48 86 5 0 0 0 - - -;
#X text 119 31 <-- paste this subpatch into;
#X text 32 4 bang for list of arguments;
#X text 151 46 your abstraction;
#X obj 14 109 print creation_arguments;
#X text 14 138 * outputs a bang if no arguments are given;
#X connect 0 0 1 0;
#X connect 1 0 2 0;
#X connect 1 0 7 0;
#X connect 2 0 3 0;
#N canvas 478 416 320 90 12;
#X text 132 29 the subpatch;
#X text 12 10 A test patch-- click inside for;
#X obj 12 58 my_abstraction one 2 three 40 512;


signature.asc
Description: OpenPGP digital signature
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] Abstraction arguments: tell apart symbols from floats from no argument at all

2018-12-22 Thread Jérôme Abel

Hi all,

Some vanilla solutions in attachments, taken from some projects.

++

--
Jérôme Abel
http://jeromeabel.net

#N canvas 13 101 902 398 10;
#X obj 110 127 route float symbol;
#X obj 110 84 route bang;
#X obj 110 63 list;
#X obj 110 39 loadbang;
#X obj 110 105 list append \$1;
#X obj 458 58 loadbang;
#X msg 458 127 0;
#X obj 458 78 symbol test-\$1;
#X obj 515 118 t b;
#X obj 387 223 route 0;
#X obj 387 245 t b;
#X obj 458 98 sel test-0;
#X obj 387 319 bng 15 250 50 0 empty empty no_arg 17 7 0 10 -262144
-1 -1;
#X obj 451 274 bng 15 250 50 0 empty empty a_float 17 7 0 10 -262144
-1 -1;
#X floatatom 426 248 5 0 0 0 - - -, f 5;
#X text 457 31 Test if tere is no argument;
#X obj 515 206 route float symbol;
#X obj 515 163 route bang;
#X obj 515 142 list;
#X obj 515 184 list append \$1;
#X obj 587 266 bng 15 250 50 0 empty empty a_symbol 17 7 0 10 -262144
-1 -1;
#X symbolatom 567 236 10 0 0 0 - - -, f 10;
#X obj 387 344 print \$0-NO-ARG;
#X obj 426 295 print \$0-FLOAT;
#X obj 567 295 print \$0-SYMBOL;
#X obj 162 154 print \$0-SYMBOL_ARG;
#X obj 110 179 print \$0-FLOAT_ARG;
#X connect 0 0 26 0;
#X connect 0 1 25 0;
#X connect 1 0 4 0;
#X connect 2 0 1 0;
#X connect 3 0 2 0;
#X connect 4 0 0 0;
#X connect 5 0 7 0;
#X connect 6 0 14 0;
#X connect 7 0 11 0;
#X connect 8 0 18 0;
#X connect 9 0 10 0;
#X connect 9 1 14 0;
#X connect 10 0 12 0;
#X connect 11 0 6 0;
#X connect 11 1 8 0;
#X connect 12 0 22 0;
#X connect 14 0 13 0;
#X connect 14 0 23 0;
#X connect 16 0 9 0;
#X connect 16 1 21 0;
#X connect 17 0 19 0;
#X connect 18 0 17 0;
#X connect 19 0 16 0;
#X connect 21 0 20 0;
#X connect 21 0 24 0;
#N canvas 482 360 450 300 10;
#X obj 166 80 test_arguments;
#X obj 166 108 test_arguments 10;
#X obj 166 138 test_arguments data/test.txt;
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] Abstraction arguments: tell apart symbols from floats from no argument at all

2018-12-22 Thread Peter P.
* hans w. koch  [2018-12-22 19:28]:
> i have this vanilla abstraction based on a patch by johannes, which gives 1 
> for argument present and 0 if absent
> maybe thats for you?

Thanks Hans, this looks good and seems to be a similar way than the one
proposed by Christof.

best, P
> 
> best hans



___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] Abstraction arguments: tell apart symbols from floats from no argument at all

2018-12-22 Thread hans w. koch
i have this vanilla abstraction based on a patch by johannes, which gives 1 for 
argument present and 0 if absent
maybe thats for you?

best hans



checkarg.pd
Description: Binary data


argtest.pd
Description: Binary data


> Am 22.12.2018 um 16:52 schrieb Matt Davey :
> 
> If you're ok with using an external library, then there is [pofutil] in the 
> pof library which outputs a list of arguments when sent a [dollarg( message.
> 
> so, like:
> 
> [dollarg(
> |
> [pofutil]
> 
> You can then just use pd's list functions (list length, list split, etc) to 
> pull that list apart and check its length, etc. 
> 
> [route symbol float] should do the last bit you wanted, 
> 
> ___
> Pd-list@lists.iem.at mailing list
> UNSUBSCRIBE and account-management -> 
> https://lists.puredata.info/listinfo/pd-list

___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] Abstraction arguments: tell apart symbols from floats from no argument at all

2018-12-22 Thread Christof Ressi
unfortunately, this doesn't work. missing arguments will become 0 and therefore 
can't be differentiated from a float arg with with the same value. I think it's 
only dollarsyms (e.g. "_$1") where the missing argument doesn't become 0.

I think Pd vanilla really needs a mechanism to retreive the creation arguments 
as a list. personally I quite like $@.

> Gesendet: Samstag, 22. Dezember 2018 um 19:00 Uhr
> Von: "João Pais" 
> An: pd-list , "Peter P." 
> Betreff: Re: [PD] Abstraction arguments: tell apart symbols from floats from 
> no argument at all
>
> another way to do it might be the following. I don't have now the time to  
> test it:
> 
> - loadbang a list with all the arguments (maybe initiated by something  
> like [list $1 $2 $3 ... $16 or whatever])
> - use an abstraction from list-abs to drip the list
> - send the output through a route to test the type
> 
> If you know beforehand that 0s won't be part of the arguments, it will be  
> even easier, just filter out the 0s when detecting the argument type.
> 
> 
> > * Christof Ressi  [2018-12-22 17:15]:
> >> if you're ok with externals you can also use [dollarg] from iemlib or  
> >> [canvasargs] from iemguts. for a hacky vanilla solution, see attached  
> >> patch. I'm sure there are more ways, this is just one that I remembered.
> > And it is a nice one, Thanks Christof!
> 
> 
> 
> ___
> Pd-list@lists.iem.at mailing list
> UNSUBSCRIBE and account-management -> 
> https://lists.puredata.info/listinfo/pd-list
>



___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] Abstraction arguments: tell apart symbols from floats from no argument at all

2018-12-22 Thread João Pais
another way to do it might be the following. I don't have now the time to  
test it:


- loadbang a list with all the arguments (maybe initiated by something  
like [list $1 $2 $3 ... $16 or whatever])

- use an abstraction from list-abs to drip the list
- send the output through a route to test the type

If you know beforehand that 0s won't be part of the arguments, it will be  
even easier, just filter out the 0s when detecting the argument type.




* Christof Ressi  [2018-12-22 17:15]:
if you're ok with externals you can also use [dollarg] from iemlib or  
[canvasargs] from iemguts. for a hacky vanilla solution, see attached  
patch. I'm sure there are more ways, this is just one that I remembered.

And it is a nice one, Thanks Christof!




___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] Abstraction arguments: tell apart symbols from floats from no argument at all

2018-12-22 Thread Peter P.
* Christof Ressi  [2018-12-22 17:15]:
> if you're ok with externals you can also use [dollarg] from iemlib or 
> [canvasargs] from iemguts. for a hacky vanilla solution, see attached patch. 
> I'm sure there are more ways, this is just one that I remembered.
And it is a nice one, Thanks Christof!
P



___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] Abstraction arguments: tell apart symbols from floats from no argument at all

2018-12-22 Thread Christof Ressi
if you're ok with externals you can also use [dollarg] from iemlib or 
[canvasargs] from iemguts. for a hacky vanilla solution, see attached patch. 
I'm sure there are more ways, this is just one that I remembered.
 
Christof 

Gesendet: Samstag, 22. Dezember 2018 um 16:52 Uhr
Von: "Matt Davey" 
An: "Peter P." 
Cc: pd-list 
Betreff: Re: [PD] Abstraction arguments: tell apart symbols from floats from no 
argument at all

If you're ok with using an external library, then there is [pofutil] in the pof 
library which outputs a list of arguments when sent a [dollarg( message.
 
so, like:

[dollarg(
|
[pofutil]
 
You can then just use pd's list functions (list length, list split, etc) to 
pull that list apart and check its length, etc. 
 
[route symbol float] should do the last bit you wanted, 
 ___ Pd-list@lists.iem.at mailing 
list UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list

arg-test.pd
Description: Binary data


arg-test-abs.pd
Description: Binary data
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] Abstraction arguments: tell apart symbols from floats from no argument at all

2018-12-22 Thread Matt Davey
If you're ok with using an external library, then there is [pofutil] in the
pof library which outputs a list of arguments when sent a [dollarg( message.

so, like:

[dollarg(
|
[pofutil]

You can then just use pd's list functions (list length, list split, etc) to
pull that list apart and check its length, etc.

[route symbol float] should do the last bit you wanted,
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


[PD] Abstraction arguments: tell apart symbols from floats from no argument at all

2018-12-22 Thread Peter P.
Hi list,

please excuse me if this has been discussed numerous times, but the
search engine at https://lists.puredata.info/pipermail/pd-list/ does not
give me reasonable answers.

I am writing an abstraction and for one of its numeric arguments I would
like to detect if it has been not specified, or if it has been set to a
float including 0. How can I do this?

I would also like to detect if another argument is a float or a symbol and
process these two differently without causing Pd error messages. Is this
possible?

Thank you!
P



___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list