Passing arguments to a function
#1

Hello,

Maybe someone will know better way of doing this:

Код:
m_query(const query[], const callback[] = "", const format[] = "", {Float, _}:...)
{
	new
		args = numargs();

	if(args > 3)
	{
                switch(args)
                {
                        case 4: mysql_tquery(gSQL, query, callback, format, getarg(3));
                        case 5: mysql_tquery(gSQL, query, callback, format, getarg(3), getarg(4));
                        case 6: mysql_tquery(gSQL, query, callback, format, getarg(3), getarg(4), getarg(5));
                        case 7: mysql_tquery(gSQL, query, callback, format, getarg(3), getarg(4), getarg(5), getarg(6));
                        case 8: mysql_tquery(gSQL, query, callback, format, getarg(3), getarg(4), getarg(5), getarg(6), getarg(7));
                        case 9: mysql_tquery(gSQL, query, callback, format, getarg(3), getarg(4), getarg(5), getarg(6), getarg(7), getarg(8));
                 }
	}
	else
	{
		mysql_tquery(gSQL, query);
	}
}
There is one big downside - I have to write new line for every possible argument count. I can't use #define in this place.
Reply


Messages In This Thread
Passing arguments to a function - by Scottas - 04.06.2017, 10:47
Re: Passing arguments to a function - by GoldenLion - 04.06.2017, 11:12
Re: Passing arguments to a function - by Dayvison_ - 04.06.2017, 12:06
Re: Passing arguments to a function - by Scottas - 04.06.2017, 12:07
Re: Passing arguments to a function - by Scottas - 04.06.2017, 21:24

Forum Jump:


Users browsing this thread: 1 Guest(s)