•
The end of a multiline comment can be followed on the same line by active code. For example,
the following line is valid, although it is poor coding practice:
End of my long comment */ foo = "bar";
•
You can use multiline format for a comment on a single line, for example:
/*This is a single line comment using multiline format. */
•
You cannot nest /* and */ markers inside other comment lines.
Reserved words
In addition to the names of ColdFusion functions and words reserved by ColdFusion expressions
(such as NOT, AND, IS, and so on), the following words are reserved in CFScript. Do not use
these words as variables or identifiers in your scripting code:
break
case
catch
continue
Differences from JavaScript
Although CFScript and JavaScript are similar, they have several key differences. The following list
identifies CFScript features that differ from JavaScript:
•
CFScript uses ColdFusion expressions, which are neither a subset nor a superset of JavaScript
expressions. For example, there is no < operator in CFScript; you use the LT operator instead.
•
Variable declarations are only used in user-defined functions.
•
CFScript is case-insensitive.
•
All statements end with a semicolon and line breaks in the code are ignored.
•
Assignments are statements, not expressions.
•
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
inside other ColdFusion tags, such as
CFScript functional equivalents to ColdFusion tags
Tag
cfset
cfoutput
cfif, cfelseif,
cfswitch, cfcase,
cfdefaultcase
default
do
else
for
cfoutput.
CFScript equivalent
Direct assignment, such as Myvar=1;
WriteOutput
if and else statements
cfelse
switch, case, and default statements
function
if
in
return
function
switch
try
var
while
blocks
cfscript
The CFScript language
131
Need help?
Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?
Questions and answers