It doesn't look like variable argument lists are supported in RobotC, however, it looks like defaulting function parameters to a predefined value might be. In this case, the function prototype looks something like the following:
function_name(0);
function_name(0, "it works");
function_name,(0, "it works", "it still works");
I further suggest that within the logging function, we make changes so that only the supplied values are logged and perhaps even expand the number of arguments so that it takes are series of argument pairs...we can then change the prototype to something like:
This will allow us to remove the extraneous fields from the log file and make it more readable by adding one or more meaningful labels to each value recorded.
It doesn't look like variable argument lists are supported in RobotC, however, it looks like defaulting function parameters to a predefined value might be. In this case, the function prototype looks something like the following:
void function_name(int arg1, string arg2 = NULL, string arg3 = NULL);
you can then call the function in one of 3 ways:
function_name(0); function_name(0, "it works"); function_name,(0, "it works", "it still works");
I further suggest that within the logging function, we make changes so that only the supplied values are logged and perhaps even expand the number of arguments so that it takes are series of argument pairs...we can then change the prototype to something like:
void log(const char*, string, string=NULL, int=0, string=NULL, int=0, string=NULL, int=0);
..and then call the function like:
log(FILE, "reset angle sensor", "old=", old_value, "new=", new_value);
it would then print a line like:
"reset angle sensor old=100 new=0"