create "myFunction" outside of "someFunction", but call it from within.
<CFComponent Name="SomeName">
<CFFunction Name="SomeFunction" Output="False" ReturnType="String">
<!--- here's where you call it insted of creating it --->
<cfset myVar = myFunction(someArgument) />
</CFFunction>
<cfscript>
function MyFunction(arg) {
return arg;
}
</cfscript>
</CFComponent>
You'll notice that I left the 'MyFunction' function in
<cfscript>...which is legal. But here's some more advice that you
never asked for. Bear in mind this comes from someone who loves the
heck out of <cfscript>. I just prefer the syntax, it's less typing
for things like setting variables, etc. But, i always use
<cffunction> in my CFCs. <cffunction> just offers so much more over
<cfscript> functions (IMO) just because of the <cfargument> tag. Now,
you -could- create your <cffunction> with your <cfargument> tags and
write the rest of the function in <cfscript>. However, I don't care
for that myself. It's just a matter of preference, but as somebody
else has already pointed out, I like to see consistency in the code.
Seeing cf tags mixed in with cfscript all willy-nilly is one of those
things that makes that vein in my forehead start to pulsate :)
On 12/16/06, Christopher Jordan <[EMAIL PROTECTED]> wrote:
> Thanks Mark. Can you (or anyone really), show me the proper way to do this?
>
> Cheers,
> Chris
>
> Mark A Kruger wrote:
> > Chris,
> >
> > I'd say our problem isn't cfscript (which I use routinely inside of a
> > cffunction tag). You problem is that you are declaring a functions inside of
> > a function.
> >
> > -mark
> >
> >
> > -----Original Message-----
> > From: Christopher Jordan [mailto:[EMAIL PROTECTED]
> > Sent: Friday, December 15, 2006 9:34 PM
> > To: CF-Talk
> > Subject: CFScript inside a CFC
> >
> > Hi folks,
> >
> > I've got a CFC with a function in it that contains CFScript tags. Like this:
> >
> > <CFComponent Name="SomeName">
> > <CFFunction Name="SomeFunction" Output="False" ReturnType="String">
> > <cfscript>
> > function MyFunction(arg) {
> > return arg;
> > }
> > </cfscript>
> > </CFFunction>
> > </CFComponent>
> >
> > BlueDragon seems to have absolutely no problems with this, but my host's
> > CFMX box pukes over this.
> >
> > What's the deal? This is the first time I've tried to use CFScript tags
> > inside of a component. I was told by some members of my local CFUG that
> > writing code within CFScript tags whenever possible is faster (performance
> > wise), so I'm giving it a go.
> >
> > Am I doing something wrong?
> >
> > Thanks,
> > Chris
> >
> >
> >
> >
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:264250
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4