Or you could take the easy (cheap) way out:
<CFFUNCTION NAME="CreateAccount">
<CFARGUMENT NAME="lstKeyValuePairs" TYPE="String"/>
<CFSET var lstPair = "">
<CFSET var iMeetingID = "">
<CFSET var sAttending = "">
<CFLOOP LIST="#arguments.lstKeyValuePairs#" INDEX="lstPair">
<CFSET iMeetingID = ListGetAt(lstPair, 1, "=")>
<CFSET sAttending = ListGetAt(lstPair, 2, "=")>
</CFLOOP>
</CFFUNCTION>
--Then--
<CFINVOKE ... METHOD="CreateAccount">
<CFINVOKEARGUMENT NAME="lstKeyValuePairs"
VALUE="1=Bob,2=Sherry,3=Some Guy"/>
</CFINVOKE>
Especially if you're going to expose it as a WS (which it looks like you are
based on your designation of remote access), keeping input types simple
helps keep compatibility issues to a minimum.
The other alternative is, as Nathan suggested, looping through the arguments
collection. The only issue with that would be that if you don't know the
exact arguments ahead of time, WSDL/WS discovery doesn't always play nice.
.02
Roland
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Nathan Dintenfass
Sent: Friday, June 04, 2004 3:10 AM
To: [EMAIL PROTECTED]
Subject: RE: [CFCDev] Pass in "dynamic" arguments
The underlying issue, I suspect, is that CFARGUMENT is a compile-time
directive, so you can't define how many of them there will be at run-time.
Sounds like what you really want to pass is a struct of "attending" keyed
off the meetingID's you are passing in.
<cfargument name="meetingID" ...>
<cfargument name="attending" type="struct" required="false"
default="#structNew()#">
Alternatively, you could just loop from 2 to the structCount(arguments) and
grab each argument as you go, pairing it up to the MeetingID list -- that
way your end-developer can just pass in however many other arguments they
like.
On the other hand, it may be that what you really need to do is create a
different CFC that encapsulates this meeting/attending relationship and then
pass one of those as the value of your argument in createAccount.
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Brian Meloche
> Sent: Thursday, June 03, 2004 11:50 PM
> To: [EMAIL PROTECTED]
> Subject: [CFCDev] Pass in "dynamic" arguments
>
>
> I ran into a problem. Here is the code that's causing me the issue:
>
> <CFCOMPONENT>
> <CFFUNCTION name="CreateAccount" access="remote"
> returntype="string">
> ...
> <CFARGUMENT name="MeetingID" type="string" required="false">
> <CFIF IsDefined("Arguments.MeetingID")>
> <CFLOOP index="m" list="#Arguments.MeetingID#">
> <CFARGUMENT name="#evaluate(attending#m#)#"
> type="numeric" required="false">
> </CFLOOP>
> </CFIF>
> ...
> </CFFUNCTION>
> </CFCOMPONENT>
>
> What I am TRYING to do is that Arguments.MeetingID would be
> passed a list of
> meetings: e.g. 2,3,4.
>
> Based on the value of Arguments.MeetingID, I want to pass in a number and
> name of "attending" arguments into the function. In the example I gave, I
> want to be able to generate the following dynamically:
>
> <CFARGUMENT name="attending2" type="numeric" required="false">
> <CFARGUMENT name="attending3" type="numeric" required="false">
> <CFARGUMENT name="attending4" type="numeric" required="false">
>
> The loop, although logically correct, doesn't work through CFCs, as the
> CFARGUMENT tag must be wrapped in a CFFUNCTION. The CFLOOP and CFIF
> statements get in the way.
>
> So... How do I do this? I went looking throughout every email I have from
> this list, but I couldn't find this ever discussed... But I have to think
> this is a common issue, and that there is a way to do this. Do I need to
> pass this section of code to another FUNCTION?
>
> Or... Is the answer... Not to pass an argument at all?
>
> Sincerely,
>
>
> Brian Meloche,
> User Group Manager,
> Cleveland Macromedia Users Group
> http://www.clevelandmmug.org
> "A leader who knows his priorities but lacks concentration knows
> what to do
> but never gets it done. If he has concentration, but no priorities, he has
> excellence without progress. But when he harnesses both he has
> the potential
> to achieve great things." - John C. Maxwell
>
>
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[EMAIL PROTECTED]
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]