Solved

Scope order for CF 8

Posted on 2008-10-22
6
800 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
  • 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 150 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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 350 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

912 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now