Dealing with missing argument in message

Roald Baudoux's icon

Hello,

How does Max function when a message supposed to be followed by an int actually isn't? If I remember correctly, then a default value of 0 is provided. Is it correct? Then, is there any way to differentiate an actual 0 from the lack of argument?

Thank you in advance.

Roman Thilenius's icon

if you have a steady stream of data coming into a [pack yoursymbol 0. ], the pack object will output the last number when no new number is incoming.

so i guess this is a valid example where it works differently - at least for inlets other than the first.

the big exception where it seems to be standard is the famous "set" with a missing second argument, which is resetting many externals to 0, or an emtpy buffer.

Roald Baudoux's icon

Thanks Roman but my question is about C programming (maybe the "dev" tag was not precise enough?)So, if I create a function with a keyword which should be followed by an int argument, how do I detect if the argument is missing?

11OLSEN's icon

Hi, have you tried to check the input variable against NULL? Also you can use a list input. then you can check the number of args and even the type of args.

Roald Baudoux's icon

Hi, have you tried to check the input variable against NULL?

I was thinking about that. Is it correct like this?
void simplesensel_openbyid(t_simplesensel *x, long dev)
{
    if (dev != NULL) {
...
}
}

Also you can use a list input. then you can check the number of args and even the type of args.

That's an interesting path. Thank you.

Roald Baudoux's icon

After additional reading and testing, I think that the comparison with NULL excluded the possibility for the argument to have the value 0. So I'll check the second solution.