I am writing a user command ("query_getqueryvalue") that acts as a wrapper for the "query" command and "getqueryvalue" command -- this will run a query and get the first result value in one call.
I am wondering how to pass an unknown number of command inputs onto the 'query' command, since that function accepts an unknown number of inputs as dynamic query parameters (using the $ syntax). I basically want to pass any extra "..." command inputs (past the first 2) onto the internal 'query' call.
Right now I'm doing a hacky solution (below) that checks the number of inputs (with 'parqty()') and uses a switch statement to pass the right number of inputs onto 'query'. Is there a better way to do this in flexscript/C++?
/**Custom Code*/ // parameter inputs // (str col, str query[, node/num/str p1, node/num/str p2, ...]) string col = parstr(1); string query_str = parstr(2); int par_count = parqty(); // make a hacky 'query' call with the correct parameters (up to 8) switch (par_count) { case 2: query(query_str); case 3: query(query_str, param(3)); break; case 4: query(query_str, param(3), param(4)); break; case 5: query(query_str, param(3), param(4), param(5)); break; case 6: query(query_str, param(3), param(4), param(5), param(6)); break; case 7: query(query_str, param(3), param(4), param(5), param(6), param(7)); break; case 8: query(query_str, param(3), param(4), param(5), param(6), param(7), param(8)); break; case 9: query(query_str, param(3), param(4), param(5), param(6), param(7), param(8), param(9)); break; case 10: query(query_str, param(3), param(4), param(5), param(6), param(7), param(8), param(9), param(10)); break; default: query(query_str); } // get first query value var res = getqueryvalue(1, col); return(res);
See attached for a zip of my library "project" in response to @Arun KR -- this includes the source model file (source.fsx), along with input data and the output .fsl library file. The model includes this custom User Command.