varargs best practice?
Mark Wieder
mwieder at ahsoftware.net
Tue Dec 7 02:04:19 EST 2010
All-
Does anyone have ideas on a best practice for handling variable
numbers of parameters (as in C varargs)? I have two functions and I'd
like to pass a variable number of parameters (probably no more than
six) to the first function and have it hand them off to the second:
function getString pVerb, pArgs -- pArgs may be many parameters
return doCommand(pVerb, pArgs)
end getString
function doCommand pVerb, pArgs
-- do something with parameters
-- return something
end doCommand
The problem is that only the first argument gets passed to the
doCommand function. If I iterate through the parameters to getString
using paramCount and param(x) then the result gets packaged up in
quotes when it gets handed to doCommand and it becomes one parameter.
I'm about to do something really ugly with the code and hoping that
someone has been through this already and has a nifty way of dealing
with this situation.
--
-Mark Wieder
mwieder at ahsoftware.net
More information about the use-livecode
mailing list