Home arrow ColdFusion arrow Page 4 - Everything You Must Know About ColdFusion Variables
COLDFUSION

Everything You Must Know About ColdFusion Variables


Understanding ColdFusion variables and logic is vital to being able to program in the language. In this tutorial, Jay's second covering ColdFusion, you will learn about the types of ColdFusion variables and how to use them.

Author Info:
By: Jayaram Krishnaswamy
Rating: 4 stars4 stars4 stars4 stars4 stars / 25
August 15, 2005
TABLE OF CONTENTS:
  1. · Everything You Must Know About ColdFusion Variables
  2. · Developing ColdFusion Content
  3. · Variable definition with CFSET tag
  4. · Variable by assigning statements in CFSCRIPT
  5. · Scope of a variable
  6. · Data Type Category of Variables
  7. · How do we name a variable?

print this article
SEARCH DEVARTICLES

Everything You Must Know About ColdFusion Variables - Variable by assigning statements in CFSCRIPT
(Page 4 of 7 )

It was mentioned earlier that CFSCRIPT can be used to assign variables. Here is an example of such an assignment. In CSPT.cfm, three numbers are assigned to the variables m, n, and p. There are rules to be followed in using CFSCRIPT, but these will be discussed later. Notice the ColdFusion comment. It has an extra dash, three compared to two in an HTML comment.

Syntax
<CFSCRIPT>
The CFSCRIPT code goes here, review the example
</CFSCRIPT>
<!--- Usage of CFSCRIPT--->
<!---File Name:CSPT.cfm--->
<cfscript>
m=5;
n=1.5;
p=2;
WriteOutput("The value of (5 + 1.5) divided by 2 is: ");
WriteOutput((n+m)/p);
</cfscript>

This code will be processed by the CFMX as shown in this picture. CFSCRIPT is only processed by the server. It may not contain CFML tags, and statements are terminated by a semicolon (similar to JavaScript). The same assignment with CFML would have taken three <cfset /> tags plus the <cfoutput />. The display in CFSCRIPT is by using the WriteOutput() syntax. You may also notice the absence of CFML tags inside <cfscript />

Characteristics of Variables

Variables in ColdFusion are characterized by the following:

  • Scope of the variable -- This covers where and how long the variable is accessible.
  • Data type of the variable -- This covers the kind of information that the variable represents, number, strings, Boolean, and so on.

blog comments powered by Disqus
COLDFUSION ARTICLES

- Adobe ColdFusion Just Got More RAD
- 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...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials