Ah, the light bulb just came on. Thanks. Walt
-----Original Message----- From: Sean A Corfield [mailto:[EMAIL PROTECTED] Sent: Friday, March 19, 2004 8:43 PM To: [EMAIL PROTECTED] Subject: Re: [CFCDev] Unscoped references in CFSET within CFFUNCTION On Mar 19, 2004, at 3:41 PM, Sparrow-Hood, Walter wrote: > I thought that if you didn't scope a variable within a function it > was, by default, in the 'variables' scope and available outside the > function > and bad things could happen. If you didn't previously declare it with 'var' (or, as Barney observed, if it isn't an argument). > Which his why you always scope internal variable in the 'var' scope. You can't scope a local 'var' variable - you can scope instance variables ('variables' scope) and arguments ('arguments' scope). That's why it's so important to have local variables explicitly declared with 'var' at the top of the function: <cfset var localVar = 0 /> <cfset var someValue = 42 /> ... <cfset localVar = someValue /> You don't need to do that with instance variables (or arguments) - you can just scope-qualify them: <cfset variables.instanceVar = arguments.someValue /> Regards, Sean ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com). An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED] ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com). An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
