[PD-dev] some tclpd questions/comments

mescalinum at gmail.com mescalinum at gmail.com
Thu Nov 10 22:27:31 CET 2011


Il 08/11/2011 04:10, Hans-Christoph Steiner ha scritto:
> I can imagine that for an full library written with tclpd, there would be shared code between the objects.

tcl has a package system for that. (package provide / require)

> I have another question: with proc+ 0_symbol I seem to get "\{symbol blah\}" as $args.  That's really hard to work with, how about making 0_symbol $args just be the symbol itself, i.e. "blah". This is what I had to do to get it to work:
>
>      set @filename [lindex {*}$args 1]

pd lists (that is: atom lists) are just plain (tcl) lists of atoms.
pd atoms in tcl are represented as {selector value}, for example {float 
42} or {symbol blah}.

there are a couple of procs in tclpdlib for simplifying that.

for example you should use:

     set @filename [pd::arg 0]

(I commited this fix for you).
If you want full control over input, here's an example:

     set atom0 [lindex $args 0]

     set selector [lindex $atom0 0]
     set value [lindex $atom0 1]

     if {$selector ne "symbol"} {
         return -code error "first argument must be a symbol!"
     }

     # ...

     by the way, for requiring a specific selector, you can just use:

     set symbol0 [pd::arg 0 symbol]

>
> Also, I couldn't figure out how to output a float to the outlet, my attempt creates a message that is "float 1" but not a float:
>
>      pd::outlet $self 0 [list float [file exists $@filename]]

wrong.
the signature of pd::outlet is:

proc outlet {self n sel args} { ... }

so you should call:

     pd::outlet $self $outlet_num list $list

for outputting a list, or in your case:

     pd::outlet $self 0 float [file exists $@filename]

for outputting a float (I commited this fix as well)


bye



More information about the Pd-dev mailing list