Hello, 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.
Right now, I have to make sure that my variable names are unique inside and outside function definitions. This is quite burdensome, making it difficult to easily name variables inside of functions to ensure I am not overwriting variables in the callers scope. It is also difficult for people to use my functions, since beside knowing my function name, its arguments, and what it returns, they must also know what variables I am using for internal function processing to ensure that their variables are not overwritten. Here is a basic example: <!--- page function.cfm ---> <!--- this function is included via <cfinclude> from another page ---> <cffunction name="add_two_numbers"> <cfargument name="first" required="true"> <cfargument name="second" required="true"> <cfset sum=arguments.first + arguments.second> <cfreturn sum> </cffunction> <!--- page that uses the function ---> <cfinclude template="functions.cfm"> <!--- using sum to track addition of numbers ---> <cfset sum=12> <!--- sum is now 12 ---> <cfset result=add_two_numbers(1, 2)> <!--- sum is now 3 (changed in function), when I want it to be 12 ---> <cfset sum=sum + result> <!--- sum is now 6, when I want it to be 15 ---> I looked in the MM documentation, but I could not find an appropriate answer to this question. Thanks! Jon ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| 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 Get the mailserver that powers this list at http://www.coolfusion.com Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

