With CF9 you don't need the var keyword anymore, and if you don't need backwards compatible code it's (arguably) clearer to not use it at all.
That means, do NOT use either of your examples, unless you _need_ a value in myvar1/myvar2 at the start. Perhaps a good way to explain it is to use some sample functions... this is just a bit of nonsense code, but hopefully demonstrates the different ways to do it... <cffunction name="test_cf8_var"> <--- [imagine arguments here] ---> <cfset var myVar1 = "" /> <cfset var myVar2 = "" /> <cfif Arguments.Something EQ "whatever"> <cfset myVar1 = "wibble" /> </cfif> <cfloop index="myVar2" from=0 to=10 > <cfset myVar1 &= Variables.Data[myVar2] /> </cfloop> <cfif len(myVar1)> <cfreturn myVar1 /> <cfelse> <cfreturn "burp" /> </cfif> </cffunction> <cffunction name="test_cf8_local"> <--- [imagine arguments here] ---> <cfset var local = StructNew() /> <cfif Arguments.Something EQ "whatever"> <cfset local.myVar1 = "wibble" /> <cfelse> <cfset local.myVar1 = "" /> </cfif> <cfloop index="local.myVar2" from=0 to=10 > <cfset local.myVar1 &= Variables.Data[local.myVar2] /> </cfloop> <cfif len(local.myVar1)> <cfreturn local.myVar1 /> <cfelse> <cfreturn "burp" /> </cfif> </cffunction> <cffunction name="test_cf9"> <--- [imagine arguments here] ---> <cfif Arguments.Something EQ "whatever"> <cfset local.myVar1 = "wibble" /> <cfelse> <cfset local.myVar1 = "" /> </cfif> <cfloop index="local.myVar2" from=0 to=10 > <cfset local.myVar1 &= Variables.Data[local.myVar2] /> </cfloop> <cfif len(local.myVar1)> <cfreturn local.myVar1 /> <cfelse> <cfreturn "burp" /> </cfif> </cffunction> ...does that make sense? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346491 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm