Hans-Christoph Steiner wrote:
We have a winner! :D
darn, i just finished an example that works as well....
fmasdr.
IOhannes
/******************************************************
*
* myname - implementation file
*
* copyleft (c) IOhannes m zm-bölnig-A
*
* 2007:forum::f-bür::umläute:2007-A
*
* institute of electronic music and acoustics (iem)
*
******************************************************
*
* license: GNU General Public License v.2
*
******************************************************/
/*
* this object is an example on how to retrieve the object's own name
* usage:
* + bang to print the object's name to the console
*/
#include "m_pd.h"
/* ------------------------- myname ---------------------------- */
static t_class *myname_class;
typedef struct _myname
{
t_object x_obj;
} t_myname;
static void myname_bang(t_myname *x) {
t_text t=(t_text)x->x_obj;
t_binbuf*b=t.te_binbuf;
if(b!=0) {
t_atom*ap=binbuf_getvec(b);
post("my name is '%s'", atom_getsymbol(ap)->s_name);
} else {
post("hmm, i don't know my name");
}
}
static void *myname_new(void)
{
t_myname *x = (t_myname *)pd_new(myname_class);
t_text t=(t_text)x->x_obj;
t_binbuf*b=t.te_binbuf;
if(b!=0) {
t_atom*ap=binbuf_getvec(b);
post("my name is '%s'", atom_getsymbol(ap)->s_name);
} else {
post("i don't know my name yet...");
}
return (x);
}
void myname_setup(void)
{
myname_class = class_new(gensym("myname"), (t_newmethod)myname_new,
0, sizeof(t_myname), 0, 0);
class_addbang(myname_class, myname_bang);
}