Solved

Scope order for CF 8

Posted on 2008-10-22
6
804 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 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
Containers and Docker for Everyone

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

 
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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

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…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

728 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