Any chance this will ever be possible?

<cffunction ...>
        <cfargument ...>
        <cfscript>
                var x = 1;
                var y = 2;

It always seems to throw the "vars need to specified at the top" error,
since <cfscript> tag comes first. I'm not really sure why 'var' is even
a part of cfscript seeing how it can never be used.

Adam Wayne Lehman
Web Systems Developer
Johns Hopkins Bloomberg School of Public Health
Distance Education Division


-----Original Message-----
From: Raymond Camden [mailto:[EMAIL PROTECTED]] 
Sent: Friday, January 24, 2003 10:30 AM
To: CF-Talk
Subject: RE: Protecting scope of <cffunction> variables

> I am writing UDF's on MX using <cffunction>, and I would like 
> to know what 
> the best way to create local variables for use inside my 
> functions that will 
> not interfere with variables in the caller's scope.

The only and only way is with the var scope. Simply do:

<cffunction ...>
        <cfargument ....>
        <cfset var x = 1>
        <cfset var y = 2>

Be sure to remember that the cfquery tag, if used with name="", also
creates a variable. If I use a query in a cffunction tag, I'll typically
do:

        <cfset var theQuery = "">

=======================================================================
Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc

Email    : [EMAIL PROTECTED]
WWW      : www.camdenfamily.com/morpheus
Yahoo IM : morpheus

"My ally is the Force, and a powerful ally it is." - Yoda 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to