my abstraction accepts two creation parameters ($1, $2). i want to make $2 optional, but it should default to value 1 if $2 was omitted.
i tried in this way:
[loadbang] | [trigger bang bang] | | [$2 ] [1 ] | / | / [float ]
but if i omit $2, the float's value is 0 and not 1. how to test if a creation parameter was specified? pd doesn't provide a kinda of null-value?
Hallo, Federico hat gesagt: // Federico wrote:
my abstraction accepts two creation parameters ($1, $2). i want to make $2 optional, but it should default to value 1 if $2 was omitted.
i tried in this way:
[loadbang] | [trigger bang bang] | | [$2 ] [1 ] | / | / [float ]
but if i omit $2, the float's value is 0 and not 1. how to test if a creation parameter was specified?
You test, if it's 0!
loadbang | [f $2] | [select 0] | | [default( | | / [s something]
Replace "default" with your default.
Frank Barknecht _ ______footils.org__
On Thu, 16 Dec 2004 08:07:16 +0100 Frank Barknecht fbar@footils.org wrote:
but if i omit $2, the float's value is 0 and not 1. how to test if a creation parameter was specified?
You test, if it's 0!
loadbang | [f $2] | [select 0] | | [default( | | / [s something]
Replace "default" with your default.
in this case, if i specify 0 as second argument, internally i get [default-value] instead of zero. inn other programming languages, you can test $2 against a null val, or you can check the argument count...
thanks. Federico
Federico wrote:
On Thu, 16 Dec 2004 08:07:16 +0100 Frank Barknecht fbar@footils.org wrote:
but if i omit $2, the float's value is 0 and not 1. how to test if a creation parameter was specified?
You test, if it's 0!
loadbang | [f $2] | [select 0] | | [default( | | / [s something]
Replace "default" with your default.
in this case, if i specify 0 as second argument, internally i get [default-value] instead of zero.
yes.
in other programming languages, you can test $2 against a null val, or you can check the argument count...
yes, that is in other languages. (well, what frank proposed was basically a testing against a null-val)
in (pure) pd this is unsfortunately not possible yet, which brings back the issue of (argc,argv) pairs, both for messages and patch-arguments. i would strongly vote vor $# and $@ as it is bash-compatible, and (for me) it is pd-compatible too: it only uses one letter, and this letter is somewhat special (unlike $n)
there is a [$n] object in the iemlib, that gives you both the length and the list of arguments of the patch it is in.
mfg.a.dsr IOhannes