Thanks for the reply.

Building on your argumentCollection suggestion, I think I've got it
figured out. I could just pass the whole arguments collection via
argumentCollection. Here's an example:

<!--- Public method --->
<cffunction name="formatName" access="public" returntype="string">
  <cfargument name="lastName" type="string" required="yes">
  <cfargument name="middleInit" type="string" required="no">
  <cfargument name="firstName" type="string" required="no">
  <cfset var formattedName = "">  
  <cfscript>
  formattedName = "<b>"
    // ######## This wraps up what I'm talking about ########
    & concatName(argumentCollection=arguments)
    & "</b>";
  </cfscript>
  <cfreturn formattedName>
</cffunction>

<!--- Helper method --->
<cffunction name="concatName" access="private" returntype="string">
  <cfargument name="lastName" type="string" required="yes">
  <cfargument name="middleInit" type="string" required="no">
  <cfargument name="firstName" type="string" required="no">
  <cfset var fullName = "">
  <cfscript>
    if (isdefined("arguments.firstName"))
      var = arguments.firstName;
    if (isdefined("arguments.middleInit"))
      var = var & " " & arguments.middleInit & ".";
    var = var & " " & arguments.lastName;
  </cfscript>   
</cffunction>

Thanks,
Jamie

On Tue, 25 Nov 2003 09:34:48 -0600, in cf-talk you wrote:

>I'm a bit confused, but are you saying you need a way to call a method and
>dynamically pass in certain arguments? If so, just use argumentCollection.
>
>s = structNew();
>if(today is a special day) {
> s.foo = 1;
>}
>s.goo = 1;
>
>x = methodName(argumentCollection=s);
>
>When you use argumentCollection, every key of the struct acts like a normal
>argument. So, if today is special, my code would act like...
>
>x = methodName(foo=1,goo=1)
>
>If today is not special, it would act like
>
>x = methodName(goo=1);
>
>You can use the same syntax when calling UDFs as well. You can also use
>attributeCollection to use the same feature when calling custom tags.
>
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to