Just for the archive, here's a very minimal object that detects the type
of the arguments:
```
#include <m_pd.h>
static t_class *var_args_class;
typedef struct _var_args {
t_object x_obj;
} t_var_args;
void *var_args_new(t_symbol *s, int argc, t_atom *argv)
{
t_var_args *x = (t_var_args *)pd_new(var_args_class);
int i;
for (i = 0; i < argc; i++) {
if (argv->a_type == A_FLOAT) {
float f = atom_getfloat(argv);
post("argumenat at position %d is float: %f",
i, f);
}
else if (argv->a_type == A_SYMBOL) {
t_symbol *s_local = atom_gensym(argv);
post("argument at position %d is symbol: %s",
i, s_local->s_name);
}
argv++;
}
return (x);
}
void var_args_setup(void)
{
var_args_class = class_new(gensym("var_args"),
(t_newmethod)var_args_new,
0, sizeof(t_var_args), CLASS_DEFAULT, A_GIMME, 0);
}
```
On 9/12/23 22:15, Alexandros Drymonitis wrote:
Or actually, argv->a.type == A_FLOAT. Sorry for clogging the list,
just wanted to pass the correct information, unless I'm wrong again...
On 9/12/23 19:30, Alexandros Drymonitis wrote:
I replied a bit too fast, I guess it should be argv.a_type == A_FLOAT
and likewise for symbol. I'll give it a try.
On 9/12/23 19:28, Alexandros Drymonitis wrote:
Does this mean that I have to check sort of like this:
if (argv == A_FLOAT) {
/* do something with the float arg */
}
else if (argv == A_SYMBOL) {
/* do something with the symbol arg */
}
On 9/12/23 18:55, IOhannes m zmölnig wrote:
https://github.com/pure-data/externals-howto#class_new-1
https://github.com/pure-data/externals-howto#atoms
mfg.sfg.jfd
IOhannes
_______________________________________________
Pd-dev mailing list
[email protected]
https://lists.puredata.info/listinfo/pd-dev
_______________________________________________
Pd-dev mailing list
[email protected]
https://lists.puredata.info/listinfo/pd-dev