varargs best practice?

Bob Sneidar bobs at twft.com
Tue Dec 7 12:13:04 EST 2010


You could pass a list if the parameters were simple types, or you could pass an array if more complex. Then you would have to get the number of items of the list, or the number of keys of the array, and loop through them. 

Bob


On Dec 6, 2010, at 11:04 PM, Mark Wieder wrote:

> 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
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list