[PD] external: method to convert t_atom to c string.
IOhannes zmölnig
zmoelnig at iem.at
Mon May 20 11:15:15 CEST 2013
On 05/20/2013 05:47 AM, J Oliver wrote:
> Hello all,
>
> I need to create a textfile from inside an external and I need to give the computer a path with a message like:
>
> path /home/path/file.txt
>
> I am therefore creating a method for path with:
>
> class_addmethod(testtext_class, (t_method)testtext_path, gensym("path"), A_GIMME, 0);
>
> Or should I use A_DEFSYMBOL ?
the A_GIMME part being covered by miller, i wanted to add that really
the way to go is to use Pd's stringish type for a path: a symbol.
the difference between A_DEFSYMBOL and A_SYMBOL is that the former
allows the user to *not* specify a symbol, whereas with A_SYMBOL the
argument is mandatory. since the "path" method doesn't make much sense
without a path, i'd go for:
<snip>
static void tettext_path(t_testtext*x, t_symbol*s) { /* ... */ }
//...
class_addmethod(testtext_class, (t_method)testtext_path, gensym("path"),
A_SYMBOL, A_NULL);
</snip>
also note that the terminating ", 0" is fine as long as you use a
C-compiler, but if you try compiling with a reasonable strict
C++-compiler, it might tell you to use ", A_NULL" instead.
gfasdr
IOhannes
More information about the Pd-list
mailing list