View comments | RSS feed
Contents > Developing ColdFusion MX Applications > Using ColdFusion Variables > About scopes PreviousNext

About scopes

Variables differ in the source of the data, the places in your code where they are meaningful, and how long their values persist. These considerations are generally referred to as a variable's scope. Commonly used scopes include the Variables scope, the default scope for variables that you create, and the Request scope, which is available for the duration of an HTTP request.

Note: User-defined functions also belong to scopes. For more information, see Specifying the scope of a function.


Contents > Developing ColdFusion MX Applications > Using ColdFusion Variables > About scopes PreviousNext

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


a440guy said on Jun 24, 2004 at 2:56 PM :
"variables differ in the source of their data": what does that mean? That is like saying the jars in my refrigerator differ in the source of their contents? What does the source have to do with it? It's the difference in the contents the important thing? Secondly, the statement is confused: the variables differ because of a property of something other than the variables. The variables don't differ, it's the contents of the variables that differ. If I'm wrong about that, please explain.

"How long their values persist" is usually called "lifetime". And, it's not just the value that persists, but the variable itself.
cf_Amir said on Sep 8, 2004 at 9:55 AM :
variables are different by their contents and lifetime.

BECAUSE they are stored, and maintained differently in server's memory. Try to use <cfdump var="#varName#"/>

create different variable such as simple variable
<cfset mySimpleVar = "John"/>
<cfdump var"#mySimpleVar #"/>
<br/>
<br/>

complex varibale
<cfscript>
employee = StructNew();
StructInsert(employee, "firstname", "John");
StructInsert(employee, "lastname", "Smith");
StructInsert(employee, "email", "me@emial.com");
StructInsert(employee, "phone", "(416) 777-7777");
StructInsert(employee, "department", "HR");
</cfscript>

<cfdump var"#employee#"/>
<br/>


---------
About varibale lifetime (scope), I should say you need to study variable scope.
Its like writing the value on sand ! or a peace of paper.
Yes, they are mostly on the server's memory (sometimes registry), but different parts of the memory are maintained DIFFERENTLY. Some expire after you close your browser window some expire when server restart , some expire after a period of time.

related links:
About scopes :: http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/variab34.htm#wp1100240
Data types :: http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/variabl5.htm#wp1122027
StructNew() :: http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/funca103.htm#wp1113520

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/variab34.htm