how to retrieve a C string from the list input of an external?
Jan 26 2014 | 11:06 pm
Maybe someone can help me with this: I want to obtain a C string from a list sent to the list inlet of a Max external. The list sent to the external is produced by packing an int and a message (sent from a message box) into a list.
So far I have used lists consisting of ints and floats. To achieve this, the function of my external looks like this:
void input_list (MyObject *x, t_symbol *msg, short argc, t_atom
* argv)
{
x being a pointer to the struct of myObject, argc indicating the number of elements of the received list and argv containing the elements of the list.
In order to obtain the elements of a list consisting of different types of data, properly, the types of the particular elements have to be specified. For example, if I want to process a list consisting of an int and a float, I will write:
if ((argc == 2) && (argv[0].a_type == A_LONG) && (argv[1].a_type
== A_Float))
{
//.... process the data
Which means: if the number of elements of the list equals 2 and the first element is an int and the second element is a float, then process the data.
Now my question is: how can I obtain a C string from a list consisting of an int and a string (produced by the message box)?
I think the code will look something like:
if ((argc == 2) && (argv[0].a_type == A_LONG) && (argv[1].a_type
== A_SYM))
{
but how can I retrieve a C string from this and copy it into an array maybe specified like this:
char my_String [31]; ?