You're right, I did misread your last post, sorry. But it's still not
super practical as a generic SES-URL-to-method-call dispatcher, unless
I'm still not getting what you mean. You'd need to inspect each method
before you called it to find out how many args it takes, pad the array
out that far, and then you'd still need a switch statement to call the
method with that specific number of arguments. Keying the switch
statement of the actual number of captured URL segments seems simpler
and less overhead.

In other words, whether the variable number of items in the array is
the number of arguments for each individual method, or the number of
URL segments actually captured, the problem of how to generically call
a method with a variable number of arguments remains. Unless you want
to find out the maximum number of arguments passed by *any* method,
and always use that, but by that time I'd think this was too clunky to
consider.

Is there some other way you're thinking of to make the actual call?

Dave

On Wed, Oct 6, 2010 at 2:33 PM, Michael Grant <mgr...@modus.bz> wrote:
>
> Re-read my last post. If you know that the method will accept x number of
> arguments. And your array may have anywhere from 1 to x possible values then
> write a function to pad your array with (x - arraylen) null values.
>
>
> Like this:
>
> <cfset positionalArgs = ['foo', 'bar', 42]>
>
> <cfset positionalArgs = padMyArray(positionalArgs,10) />
>
> <cfset myFunction(positionalArgs[1], positionalArgs[2], positionalArgs[3],
> positionalArgs[4], positionalArgs[5], positionalArgs[6], positionalArgs[7],
> positionalArgs[8], positionalArgs[9], positionalArgs[10] )>
>
> <cffunction name="padMyArray">
> <cfargument name="arrIN" type="array" required="true">
>  <cfargument name="arrLen" type="numeric" required="true">
>
> <cfloop from="#arraylen(arrIN)#" to="#arrlen#" index="x">
> <cfset ArrayAppend(arrIN,"")>
>  </cfloop>
>  <cfreturn arrIN />
> </cffunction>
>
> <cffunction name="myFunction">
> <cfargument name="arg1" required="false" default="not defined">
>  <cfargument name="arg2" required="false" default="not defined">
> <cfargument name="arg3" required="false" default="not defined">
>  <cfargument name="arg4" required="false" default="not defined">
> <cfargument name="arg5" required="false" default="not defined">
>  <cfargument name="arg6" required="false" default="not defined">
> <cfargument name="arg7" required="false" default="not defined">
>  <cfargument name="arg8" required="false" default="not defined">
> <cfargument name="arg9" required="false" default="not defined">
>  <cfargument name="arg10" required="false" default="not defined">
>  <cfdump var="arg1: #arg1#">
> <cfdump var="arg2: #arg2#">
>  <cfdump var="arg3: #arg3#">
> <cfdump var="arg4: #arg4#">
>  <cfdump var="arg5: #arg5#">
> <cfdump var="arg6: #arg6#">
>  <cfdump var="arg7: #arg7#">
> <cfdump var="arg8: #arg8#">
>  <cfdump var="arg9: #arg9#">
> <cfdump var="arg10: #arg10#">
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:337920
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to