form_errors is local to the function so that needs to be var scoped (or put in a var scoped LOCAL struct if you prefer).
You might well never see any problems if you don't var scope in your functions, but not having them can be the cause of an error that'll have you scratching your head. When I started using CFCs I'd often think, "why bother passing in the FORM scope when it's available anyway". I knew all the stock answers about encapsulation but I still thought it might not be worth it. Here's a good example of why it's a good idea. A company I work at had some code that looked at CGI.SCRIPT_NAME to pull out directories and the file name for navigation logic. We started to rewrite the URLs for art of the site and CGI.SCRIPT_NAME no longer made sense to the nav logic. Putting the code into a function and passing in the variable we needed when we needed it was the way around the problem. A lot of the time you won't be 100% sure about these sorts of things but it's worth just going along with it at least to see for yourself what all the fuss is about and whether or not it works for you in the long run. Adrian Building a database of ColdFusion errors at http://cferror.org/ -----Original Message----- From: Rick Faircloth Sent: 20 October 2008 19:58 To: cf-talk Subject: Re: How can I make this code better? Thanks for the feedback, Adrian. I'm afraid I don't quite understand what you're wanting me to do in some of your comments and why it's important. Let me ask a question about this comment you made: > If you don't fancy lots of <cfset var = someVar = ""> at the top then do one > <cfset var LOCAL = {}> and "scope" your vars as you create them <cfloop index="LOCAL.i">. Usually, in my limited experience, I only use that code when creating the cfreturn variable for the function. First, what variables need to be used in the <cfset var someVar = ""> code and why is it important to do this? Rick ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| 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:314159 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

