Symbol consisting of number

Sep 11, 2013 at 8:06am

Symbol consisting of number

Hi all,

I use the following code to generate a message in the C SDK:

t_atom msg[1];
atom_setsym(msg, atom_getsym(argv+1));

long k = 2;
char buffer[255];
sprintf(buffer, "%ld", k);
outlet_anything(x->m_outlet1, gensym(buffer), 1, msg);

The generated message looks like this:
“2″ test

What can I do to avoid the quotes? I would like to use the message in a [route 1 2 3 4] style. It seems possible to have messages starting with numbers without quotes:
<code>

– Pasted Max Patch, click to expand. –

</code>

Am I missing something here?
Thanks for any help!
Best, Boris

#264992
Sep 11, 2013 at 8:50am

Hi,

Use outlet_list instead?

t_atom a[2]; 
atom_setlong(a, 2);
atom_setsym(a + 1, gensym("toto"));
outlet_list(x->outlet, NULL, 2, a);
#264999
Sep 12, 2013 at 1:51am

Works like a charm :)
Thanks Nicolas!

#265087
Sep 13, 2013 at 6:05am

The alternative would be to pass the symbolized number through a [fromsymbol] object in your patch. But Nicolas’ approach (which I would also recommend) is much more to the point. Why turn a number into a symbol if what you want is the number, right?-)

#265195

You must be logged in to reply to this topic.