On 05/19/2013 11:47 PM, 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 ?
I'd use A_DEFSYMBOL if you want the user to be able to send a "path"
message with no args,
and A_SYMBOL if you want to require them to specify some path.
But then how can I read the atom inside the external?
I am using:
void testtext_path(t_testtext *x, t_atom *s){
char teststring[1000];
atom_string(s, teststring, 1000);
post(teststring);
}
but then I get the following printout:
consistency check failed: atom_string
333333@ÿÿÿÿs
I'm not sure where to move with this. anybody has any suggestions?
I don't have time to check it but I'd imagine the problem is that
A_GIMME assumes the method wants the following args: t_testtext*,
t_symbol*, int, and a t_atom*
where the t_symbol* refers to the selector that was used to call the
method-- in this case, the word "path". (That can come in handy, btw,
as you can have methods "chocolate" and "vanilla" point to the same
foo_icecream function and branch based on which selector was used.)
However, you only specified two arguments for that method, and one of
them is t_atom* so I guess it implicitly casts from the t_symbol* it
receives. (I think the compiler warns you about stuff like this but I'm
no expert so maybe I'm wrong.)
Then inside atom_string (in m_atom.c) it switches based on a->a_type,
but your "a" doesn't have an a_type because it's really a t_symbol*.
Thus none of the cases match and so the function ends up calling the
"bug" function that prints out the error you see.
Essentially you tried to build a string using a reference to an atom
that's not really an atom, so Pd complained that you weren't being
consistent.
-Jonathan
best,
J
Here's the info for atom_string:
atom_string
void atom_string(t_atom *a, char *buf, unsigned int bufsize);
Converts an atom |a| into a C-string |buf|. The memory to this
char-Buffer has to be reserved manually and its length has to be
declared in |bufsize|.
in:
http://pdstatic.iem.at/externals-HOWTO/node9.html#SECTION00092200000000000000
_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management ->
http://lists.puredata.info/listinfo/pd-list
_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management ->
http://lists.puredata.info/listinfo/pd-list