?
Solved

Scope order for CF 8

Posted on 2008-10-22
6
Medium Priority
?
805 Views
Last Modified: 2011-09-20
Can someone please list an order of scopes from highest to lowest in CF8?

Thanks.
0
Comment
Question by:WebStalkers
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 2

Author Comment

by:WebStalkers
ID: 22781610
Actually if you list a small paragraph of what each scope is responsible for your get the full 500 pts.

thanks
0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 22781664
Local variables
cfquery
CGI
File
URL
Form
Cookie
Client


Other scopes always need to be scoped:
Server
Application
Session
Request
Attributes
Error
0
 
LVL 19

Assisted Solution

by:erikTsomik
erikTsomik earned 600 total points
ID: 22781669
or try this
Function local (UDFs and CFCs)
Thread local (new in CF 8)
Arguments
Variables (local scope)
Thread (new in CF 8)
CGI
CFFile
URL
Form
Cookie
Client
0
AWS Certified Solutions Architect - Associate

This course has been developed to provide you with the requisite knowledge to not only pass the AWS CSA certification exam but also gain the hands-on experience required to become a qualified AWS Solutions architect working in a real-world environment.

 
LVL 2

Author Comment

by:WebStalkers
ID: 22782158
Well which is correct?  What about the 'THIS' scope?  Shouldn't that be included? Also in your first message you give me one groupe then another group that need to be included..what in what order?
Also a short description for each would be great,

Thanks
0
 
LVL 3

Accepted Solution

by:
andrewlorien earned 1400 total points
ID: 22800959
erikTsomik's second list is actually the same as his first list, with the 'local' scope unpacked a bit more.  and the order of both is correct.  ARGUMENTS.userid has priority over URL.userid which has priority over COOKIE.userid.  other scopes not in those lists (eg APPLICATION, SESSION) have to be specified explicitly
'THIS' is part of "function local" (only used in components)

it's good programming practice and more efficient for the server if you explicitly declare all variables - it does make your code a bit cumbersome, but it's worth the hours you save searching for errors.

here's a short-but-good scope definition, from http://www.quackit.com/coldfusion/tutorial/coldfusion_variable_types.cfm (re-ordered with a couple of notes)

Caller      Used within a custom tag to set or read variables within the template that called it.
This      Used within a component to store its own properties.
Variables      This scope refers to local variables that are not specifically reserved for use in custom tags. If you set a variable without specifying a scope, it will automatically belong to the variables scope.
CGI      CGI variables describe the current requests environment, are created automatically, and are read-only. You can't modify a CGI variable, only read it.
URL      Variables passed through the URL (or using the "Get" method on a form) are part of the URL scope.
Form      Variables submitted from a form using the "Post" method become part of the Form scope.
Cookie      Cookie variables are global, and persistent, variables stored on the user's machine.
Client Client variables are stored on the server, either in the registry or a database (but can also be stored in a cookie on the client machine).

these must be explicitly scoped:
Application      Application scope variables are available to a whole application
Request      The Request scope is used for the current request. These variables are non-persistent global variables.
Session      The Session scope is available for the life of a user's session.
Server      Server scope variables are available to all applications on the current server.

another list:
http://www.peachpit.com/articles/article.aspx?p=30497&seqNum=3
0
 
LVL 2

Author Comment

by:WebStalkers
ID: 22803379
this is exactly what i was looking fr,  And that seems to be a good ref site btw..thanks
0

Featured Post

Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question