
112
DEVELOPING
COLDFUSION 9 APPLICATIONS
The CFML Programming Language
Las
t
upda
te
d 8/5/2010
<cfscript>
a = 2;
</cfscript>
Variables
CFScript variables can be of any ColdFusion type, such as numbers, strings, arrays, queries, and objects. The CFScript
code can read and write any variables that are available in the page that contains the script. These variables include all
shared scopes, such as session, application, and server variables.
Expressions and operators
CFScript supports all CFML expressions. CFML expressions include operators (such as +, -, EQ, and so on), as well as
all CFML functions.
You can use several comparison operators in CFScript only, not in CFML tags. (You can also use the corresponding
CFML operators in CFScript.) The following table lists the CFScript-only operators and the equivalent operator that
you can use in CFML tags or CFScript:
For information about CFML expressions, operators, and functions, see “
Using Expressions and Number Signs
” on
page 64.
Statements
CFScript supports the following statements:
The following rules apply to statements:
•
You must put a semicolon at the end of a statement.
•
Line breaks are ignored. A single statement can cross multiple lines.
•
White space is ignored. For example, it does not matter whether you precede a semicolon with a space character.
•
Use curly brackets to group multiple statements into one logical statement unit.
•
Unless otherwise indicated, you can use any ColdFusion expression in the body of a statement.
Note:
For information on the
function
,
var
, and
return
statements, see “
Defining functions in CFScript
” on page
154.
Statement blocks
Curly bracket characters ({ and }) group multiple CFScript statements so that they are treated as a single unit or
statement. This syntax enables you to create code blocks in conditional statements, such as the following:
CFScript operator
CFML operator
CFScript operator
CFML operator
==
EQ
!=
NEQ
<
LT
<=
LTE
>
GT
>=
GTE
assignment
for-in
try-catch
function call
while
function (function definition)
if-else
do-while
var (in custom functions only)
switch-case-default
break
return (in custom functions only)
for
continue