Working With Variables; About Variables - MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual

Table of Contents

Advertisement

Working with Variables

Working with Variables

A Web application page is different from a static Web page because it can publish
data dynamically. This involves creating, manipulating, and outputting variables.
A variable stores data that you can use in applications. As with other programming
languages, you set variables in ColdFusion to store data that you want to access later.
You reference a range of variables to perform different types of application
processing.

About variables

ColdFusion variable names are case-insensitive. The variable names CITY and city
refer to the same data.
The kind of information that variables contain varies. Two characteristics distinguish
the information in a variable:
Data types
A variable's data type specifies the kind of value a variable can represent, such as a
text string or number. ColdFusion does not require you to specify a variable's data
type. Whether a variable represents a string, a number, a Boolean value (Yes/No), a
date and time, or a more complex object such as an array or structure, ColdFusion
automatically uses the appropriate internal data representation when you assign its
value. However, ColdFusion does provide methods to examine and change the type
of data that a variable represents. For a complete list of data types see the CFML
Reference.
For example, use the following syntax to create a string variable:
<cfset mystring="Hello world">
The following example uses scientific notation to create a floating-point numeric
variable:
<cfset myfloat=1.296e-3>
Scope types
Variables differ in the source the data came from, 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.
ColdFusion has many different scope types, which are identified by prefixes to a
variable name. For example, the variable
variable (a variable that has meaning on the current page). Local variables have the
optional prefix Variables. Instead of writing:
I'd like to talk to someone in #Department#.
Data type
Scope type
in calldept.cfm is a local
Department
13

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 5

Table of Contents