
114
DEVELOPING
COLDFUSION 9 APPLICATIONS
The CFML Programming Language
Las
t
upda
te
d 8/5/2010
•
All statements end with a semicolon, and line breaks in the code are ignored.
•
Assignments are statements, not expressions, and therefore cannot be used in situations that require evaluating the
assignment operation.
•
JavaScript objects, such as Window and Document, are not available.
•
Only the ColdFusion server processes CFScript. There is no client-side CFScript.
CFScript limitation
You cannot include ColdFusion tags in CFScript. However, you can include
cfscript
blocks inside other ColdFusion
tags, such as
cfoutput.
Using CFScript statements
CFScript includes the following types of statements:
•
Assignment statements and functions
•
Conditional processing statements
•
Looping statements
Using assignment statements and functions
CFScript assignment statements are the equivalent of the
cfset
tag. These statements have the following form:
lval = expression;
eval
is any ColdFusion variable reference; for example:
x = "positive";
y = x;
a[3]=5;
structure.member=10;
ArrayCopy=myArray;
You can use ColdFusion function calls, including UDFs, directly in CFScript. For example, the following line is a valid
CFScript statement:
StructInsert(employee,"lastname",FORM.lastname);
Using conditional processing statements
CFScript includes the following conditional processing statements:
•
if
and
else
statements, which serve the same purpose as the
cfif
,
cfelseif
, and
cfelse
tags
•
switch
,
case
, and
default
statements, which are the equivalents of the
cfswitch
,
cfcase
, and
cfdefaultcase
tags
Using if and else statements
The
if
and
else
statements have the following syntax:
if(expr) statement [else statement]
In its simplest form, an if statement looks as follows:
if(value EQ 2700)
message = "You've reached the maximum";
A simple if-else statement looks like the following:
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...