ColdFusion
  Home arrow ColdFusion arrow Page 5 - Everything You Must Know About ColdFusion ...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
COLDFUSION

Everything You Must Know About ColdFusion Variables
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 2 stars2 stars2 stars2 stars2 stars / 4
    2005-08-15

    Table of Contents:
  • Everything You Must Know About ColdFusion Variables
  • Developing ColdFusion Content
  • Variable definition with CFSET tag
  • Variable by assigning statements in CFSCRIPT
  • Scope of a variable
  • Data Type Category of Variables
  • How do we name a variable?

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Everything You Must Know About ColdFusion Variables - Scope of a variable


    (Page 5 of 7 )

    In general, scope refers to the time during which the variable persists (and therefore can be accessed); that is its lifetime. Some variables may last only for the duration of a session, some may last until the application is terminated. Some variables may be available in a certain portion of a program, generally inside a function, and not available outside the function. Compared to the scope of a variable in JavaScript, ColdFusion has more fine grained scope definition for its variables.

    Scopes and their types

    The scope types are listed here (taken directly from the Macromedia website) but their usage will be discussed at appropriate times when they are encountered. ColdFusion checks the scope of variables in a certain order to find the variable, and the best practice is to use the dot notation to specify the scope of a variable. For example, for a variable MyVariable in the context of a Form to be used outside the form, use Form.MyVariable to access the variable. This is very similar to JavaScript's access to control fields on a form. Both Form.MyVariable and Form["MyVariable"] are accepted notations to access MyVariable.

    • Variables; local
    • Form
    • URL
    • Attributes
    • Caller
    • This Tag
    • Request
    • CGI
    • Cookie
    • Client
    • Session
    • Application
    • Server
    • Flash
    • Arguments
    • This
    • Function Call

    Here is a CFM file that shows examples of two of the scopes from the above list, Variables and Server. Server has a set of built in variables which can be accessed as shown.

    <!--- Scope: Variables and Server scope--->
    <cfscript>
    WriteOutput("Version of ColdFusion used in this tutorial is:<br/> ");
    WriteOutput(Server.ColdFusion.ProductVersion);
    WriteOutput("<p></p>");
    tutor="Jay";
    WriteOutput("The author of this tutorial is: <br/>");
    WriteOutput(Variables.tutor);
    </cfscript>
    

    The server processed file in the browser is shown in this picture

    More ColdFusion Articles
    More By Jayaram Krishnaswamy


       · I very much would like to have your comments on this article. [b]Macromedia[/b] has...
     

    COLDFUSION ARTICLES

    - How to Access a SQL Anywhere Database with C...
    - CFXML: Probing XMLDOM in ColdFusion
    - Creating a Web Service with ColdFusion: the ...
    - CFAjax: What it is and How to Use it
    - Querying SQL 2000 Server from ColdFusion
    - Introduction to ColdFusion Markup Language, ...
    - Introduction to ColdFusion Markup Language
    - Databases and Dreamweaver MX 2004, concluded
    - Databases and Dreamweaver MX 2004
    - Welcome to Coldfusion MX 6.1, concluded
    - Welcome to Coldfusion MX 6.1
    - What You Must Know About ColdFusion Flow-Con...
    - What You Must Know About Operators in ColdFu...
    - Everything You Must Know About ColdFusion Va...
    - My First Application on ColdFusion MX Server






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT