Re: evaluation order of CF scopes
I believe those scopes need to be explicitly ...um...scoped :) e.g. cfset application.foo = bar / cfoutput#bar#/cfoutput will result in an error, since CF hunts thru the specific scopes (query, arguments, variables, cgi, url, form, client) and does not encounter 'bar' in any of them. On 10/18/05, Duncan [EMAIL PROTECTED] wrote: I was just thumbing through my CFMX7 Developer Exam StudyGuide and there is a section that lists the evaluation order of the scopes of CF. Something is bugging me though - when does application. session. server. request. get evaluated? -- Duncan I Loxton www.sixfive.co.uk http://www.sixfive.co.uk [EMAIL PROTECTED] I can only please one person per day. Today is not looking good. Tomorrow isn't looking much better. Dilbert ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:221415 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: evaluation order of CF scopes
Charlie, You mean: cfset application.foo = bar / cfoutput#foo#/cfoutput although they'll both throw the same exception. Duncan, one of my favorite spots in the livedocs (well, it was until i memorized it all...) is this one, dealing directly with your question: http://livedocs.macromedia.com/coldfusion/7/htmldocs/0911.htm Though, I think i like the one from cfmx 6.0 better: http://livedocs.macromedia.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/Variables7.htm -nathan strutz http://www.dopefly.com/ On 10/18/05, Charlie Griefer [EMAIL PROTECTED] wrote: I believe those scopes need to be explicitly ...um...scoped :) e.g. cfset application.foo = bar / cfoutput#bar#/cfoutput will result in an error, since CF hunts thru the specific scopes (query, arguments, variables, cgi, url, form, client) and does not encounter 'bar' in any of them. On 10/18/05, Duncan [EMAIL PROTECTED] wrote: I was just thumbing through my CFMX7 Developer Exam StudyGuide and there is a section that lists the evaluation order of the scopes of CF. Something is bugging me though - when does application. session. server. request. get evaluated? -- Duncan I Loxton www.sixfive.co.uk http://www.sixfive.co.uk [EMAIL PROTECTED] I can only please one person per day. Today is not looking good. Tomorrow isn't looking much better. Dilbert ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:221416 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: evaluation order of CF scopes
ok so these particular scopes dont get searched through if an unamed var is present. Do I also understand that if you do this: cfset foo = bar / cfoutput#foo#/cfoutput a) foo is actually sitting in the variables scope? b) and that foo is only available to - child templates included with cfinclude and - this current template Is this correct? On 10/19/05, Nathan Strutz [EMAIL PROTECTED] wrote: Charlie, You mean: cfset application.foo = bar / cfoutput#foo#/cfoutput although they'll both throw the same exception. Duncan, one of my favorite spots in the livedocs (well, it was until i memorized it all...) is this one, dealing directly with your question: http://livedocs.macromedia.com/coldfusion/7/htmldocs/0911.htm Though, I think i like the one from cfmx 6.0 better: http://livedocs.macromedia.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/Variables7.htm -nathan strutz http://www.dopefly.com/ On 10/18/05, Charlie Griefer [EMAIL PROTECTED] wrote: I believe those scopes need to be explicitly ...um...scoped :) e.g. cfset application.foo = bar / cfoutput#bar#/cfoutput will result in an error, since CF hunts thru the specific scopes (query, arguments, variables, cgi, url, form, client) and does not encounter 'bar' in any of them. On 10/18/05, Duncan [EMAIL PROTECTED] wrote: I was just thumbing through my CFMX7 Developer Exam StudyGuide and there is a section that lists the evaluation order of the scopes of CF. Something is bugging me though - when does application. session. server. request. get evaluated? -- Duncan I Loxton www.sixfive.co.uk http://www.sixfive.co.uk http://www.sixfive.co.uk [EMAIL PROTECTED] I can only please one person per day. Today is not looking good. Tomorrow isn't looking much better. Dilbert ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:221432 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: evaluation order of CF scopes
Yeah, cfset foo = bar / is making a variable named foo within the variables scope. On 10/18/05, Duncan [EMAIL PROTECTED] wrote: ok so these particular scopes dont get searched through if an unamed var is present. Do I also understand that if you do this: cfset foo = bar / cfoutput#foo#/cfoutput a) foo is actually sitting in the variables scope? b) and that foo is only available to - child templates included with cfinclude and - this current template Is this correct? On 10/19/05, Nathan Strutz [EMAIL PROTECTED] wrote: Charlie, You mean: cfset application.foo = bar / cfoutput#foo#/cfoutput although they'll both throw the same exception. Duncan, one of my favorite spots in the livedocs (well, it was until i memorized it all...) is this one, dealing directly with your question: http://livedocs.macromedia.com/coldfusion/7/htmldocs/0911.htm Though, I think i like the one from cfmx 6.0 better: http://livedocs.macromedia.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/Variables7.htm -nathan strutz http://www.dopefly.com/ On 10/18/05, Charlie Griefer [EMAIL PROTECTED] wrote: I believe those scopes need to be explicitly ...um...scoped :) e.g. cfset application.foo = bar / cfoutput#bar#/cfoutput will result in an error, since CF hunts thru the specific scopes (query, arguments, variables, cgi, url, form, client) and does not encounter 'bar' in any of them. On 10/18/05, Duncan [EMAIL PROTECTED] wrote: I was just thumbing through my CFMX7 Developer Exam StudyGuide and there is a section that lists the evaluation order of the scopes of CF. Something is bugging me though - when does application. session. server. request. get evaluated? -- Duncan I Loxton www.sixfive.co.uk http://www.sixfive.co.uk http://www.sixfive.co.uk http://www.sixfive.co.uk [EMAIL PROTECTED] I can only please one person per day. Today is not looking good. Tomorrow isn't looking much better. Dilbert ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:221434 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: evaluation order of CF scopes
foo would also be available to custom tags and templates included using CFMODULE in the caller scope (caller.foo). Another scope not mentioned yet is request in which variables are available throughout the life of a single request as request.varname regardless if it's called from the same page, an included page, or a custom tag/module. Request variables must be scoped (like application/session) IIRC. -Justin -Original Message- From: Duncan [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 18, 2005 10:52 PM To: CF-Talk Subject: Re: evaluation order of CF scopes ok so these particular scopes dont get searched through if an unamed var is present. Do I also understand that if you do this: cfset foo = bar / cfoutput#foo#/cfoutput a) foo is actually sitting in the variables scope? b) and that foo is only available to - child templates included with cfinclude and - this current template Is this correct? On 10/19/05, Nathan Strutz [EMAIL PROTECTED] wrote: Charlie, You mean: cfset application.foo = bar / cfoutput#foo#/cfoutput although they'll both throw the same exception. Duncan, one of my favorite spots in the livedocs (well, it was until i memorized it all...) is this one, dealing directly with your question: http://livedocs.macromedia.com/coldfusion/7/htmldocs/0911.htm Though, I think i like the one from cfmx 6.0 better: http://livedocs.macromedia.com/coldfusion/6/Developing_ColdFus ion_MX_Applications_with_CFML/Variables7.htm -nathan strutz http://www.dopefly.com/ On 10/18/05, Charlie Griefer [EMAIL PROTECTED] wrote: I believe those scopes need to be explicitly ...um...scoped :) e.g. cfset application.foo = bar / cfoutput#bar#/cfoutput will result in an error, since CF hunts thru the specific scopes (query, arguments, variables, cgi, url, form, client) and does not encounter 'bar' in any of them. On 10/18/05, Duncan [EMAIL PROTECTED] wrote: I was just thumbing through my CFMX7 Developer Exam StudyGuide and there is a section that lists the evaluation order of the scopes of CF. Something is bugging me though - when does application. session. server. request. get evaluated? -- Duncan I Loxton www.sixfive.co.uk http://www.sixfive.co.uk http://www.sixfive.co.uk [EMAIL PROTECTED] I can only please one person per day. Today is not looking good. Tomorrow isn't looking much better. Dilbert ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:221435 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: evaluation order of CF scopes
I forgot to mention, I typically will just refer to anything within the variables scope with the scope prefixed. So in your exampled I would do cfset foo = bar /cfoutput#Variables.foo#/cfoutput I have gotten into this happen due to years of working with other peoples code who hardly scope much of anything and make it a little harder to debug errors when trying to figure out where foo came in from. On 10/18/05, Aaron Rouse [EMAIL PROTECTED] wrote: Yeah, cfset foo = bar / is making a variable named foo within the variables scope. On 10/18/05, Duncan [EMAIL PROTECTED] wrote: ok so these particular scopes dont get searched through if an unamed var is present. Do I also understand that if you do this: cfset foo = bar / cfoutput#foo#/cfoutput a) foo is actually sitting in the variables scope? b) and that foo is only available to - child templates included with cfinclude and - this current template Is this correct? On 10/19/05, Nathan Strutz [EMAIL PROTECTED] wrote: Charlie, You mean: cfset application.foo = bar / cfoutput#foo#/cfoutput although they'll both throw the same exception. Duncan, one of my favorite spots in the livedocs (well, it was until i memorized it all...) is this one, dealing directly with your question: http://livedocs.macromedia.com/coldfusion/7/htmldocs/0911.htm Though, I think i like the one from cfmx 6.0 better: http://livedocs.macromedia.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/Variables7.htm -nathan strutz http://www.dopefly.com/ On 10/18/05, Charlie Griefer [EMAIL PROTECTED] wrote: I believe those scopes need to be explicitly ...um...scoped :) e.g. cfset application.foo = bar / cfoutput#bar#/cfoutput will result in an error, since CF hunts thru the specific scopes (query, arguments, variables, cgi, url, form, client) and does not encounter 'bar' in any of them. On 10/18/05, Duncan [EMAIL PROTECTED] wrote: I was just thumbing through my CFMX7 Developer Exam StudyGuide and there is a section that lists the evaluation order of the scopes of CF. Something is bugging me though - when does application. session. server. request. get evaluated? -- Duncan I Loxton www.sixfive.co.uk http://www.sixfive.co.uk http://www.sixfive.co.uk http://www.sixfive.co.uk [EMAIL PROTECTED] I can only please one person per day. Today is not looking good. Tomorrow isn't looking much better. Dilbert ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:221437 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: evaluation order of CF scopes
i second Aaron, but i'd take it a step further and scope the variable when setting it. cfset variables.foo = bar / while there are (rare) occassions when you actually don't want to scope variables, they're few and far between. a general rule of thumb is to scope all of your variables. including the local (variables) scope. On 10/18/05, Aaron Rouse [EMAIL PROTECTED] wrote: I forgot to mention, I typically will just refer to anything within the variables scope with the scope prefixed. So in your exampled I would do cfset foo = bar /cfoutput#Variables.foo#/cfoutput I have gotten into this happen due to years of working with other peoples code who hardly scope much of anything and make it a little harder to debug errors when trying to figure out where foo came in from. On 10/18/05, Aaron Rouse [EMAIL PROTECTED] wrote: Yeah, cfset foo = bar / is making a variable named foo within the variables scope. On 10/18/05, Duncan [EMAIL PROTECTED] wrote: ok so these particular scopes dont get searched through if an unamed var is present. Do I also understand that if you do this: cfset foo = bar / cfoutput#foo#/cfoutput a) foo is actually sitting in the variables scope? b) and that foo is only available to - child templates included with cfinclude and - this current template Is this correct? On 10/19/05, Nathan Strutz [EMAIL PROTECTED] wrote: Charlie, You mean: cfset application.foo = bar / cfoutput#foo#/cfoutput although they'll both throw the same exception. Duncan, one of my favorite spots in the livedocs (well, it was until i memorized it all...) is this one, dealing directly with your question: http://livedocs.macromedia.com/coldfusion/7/htmldocs/0911.htm Though, I think i like the one from cfmx 6.0 better: http://livedocs.macromedia.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/Variables7.htm -nathan strutz http://www.dopefly.com/ On 10/18/05, Charlie Griefer [EMAIL PROTECTED] wrote: I believe those scopes need to be explicitly ...um...scoped :) e.g. cfset application.foo = bar / cfoutput#bar#/cfoutput will result in an error, since CF hunts thru the specific scopes (query, arguments, variables, cgi, url, form, client) and does not encounter 'bar' in any of them. On 10/18/05, Duncan [EMAIL PROTECTED] wrote: I was just thumbing through my CFMX7 Developer Exam StudyGuide and there is a section that lists the evaluation order of the scopes of CF. Something is bugging me though - when does application. session. server. request. get evaluated? -- Duncan I Loxton www.sixfive.co.uk http://www.sixfive.co.uk http://www.sixfive.co.uk http://www.sixfive.co.uk [EMAIL PROTECTED] I can only please one person per day. Today is not looking good. Tomorrow isn't looking much better. Dilbert ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:221438 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: evaluation order of CF scopes
Lately I have been swaying on doing this myself. I do it for obvious reasons within CFCs but have yet to completely make the jump on other pages. I have been trying to focus more on naming conventions. For years I have prefixed structures with stc, queries with qry and arrays with ary but never bothered for just strings, lists, and so on. On 10/18/05, Charlie Griefer [EMAIL PROTECTED] wrote: i second Aaron, but i'd take it a step further and scope the variable when setting it. cfset variables.foo = bar / while there are (rare) occassions when you actually don't want to scope variables, they're few and far between. a general rule of thumb is to scope all of your variables. including the local (variables) scope. ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:221439 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54