>Some times it cannot be avoided with out a boat load of thinking and trial
>and error. Case in point, and I will gladly change this bit of code to not
>use evaluate if someone can figure out how to do this in CFscript sans the
>evaluate function:

OK, I'll bite. It's certainly much more verbose, and cannot be done in 
CFScript, but this should work (totally untested, obviously, so forgive any 
syntax errors):

First off, you would need to add a couple more var-scoped local variables:

<cfset var myBeanID = 0 />
<cfset var myReturnValue = "" />

And then you could change the latter portion of your function to this:

<cfif arguments.MyAction EQ "delete">
        <cfinvoke component="#myBeanObj#" method="get#arguments.MyPK#" 
returnVariable="myBeanID" />
        <cfinvoke component="#MyServiceObj#" method="delete#arguments.MyTable#" 
returnVariable="myReturnValue">
                <cfinvokeargument name="#arguments.MyPK#" value="#myBeanID#" />
        </cfinvoke>
<cfelseif arguments.MyAction EQ "Select">
        <cfinvoke component="#MygatewayObj#" method="getByAttributesQuery" 
returnVariable="myReturnValue" argumentCollection="arguments.MyStruct" />
<cfelseif arguments.MyAction EQ "Upsert">
        <cfinvoke component="#MyServiceObj#" method="save#arguments.MyTable#" 
returnVariable="myReturnValue">
                <!--- Don't know the argument name here --->
                <cfinvokeargument name="???" value="#myBeanObj#" />
        </cfinvoke>
<cfelse>
        <!--- Not sure what this is doing... does it need to return the 
evaluated numeric value 2? --->
        <cfset myReturnValue = "1+1" />
</cfif>

<cfreturn myReturnValue />

Note that you would need to supply the argument name for the "Upsert" action, 
as <cfinvokeargument> requires a name attribute, and you were using an unnamed 
argument in the original method invocation.

As I said, signifcantly more verbose, so I would leave it to your sensibilities 
as to whether this is an improvement or not...

--
Ezra Parker 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:320744
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to