Solved

Scope order for CF 8

Posted on 2008-10-22
6
802 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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

820 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