User Guide

Table Of Contents
The CFScript language 125
The CFScript language
This section explains the syntax of the CFScript language.
Identifying CFScript
You enclose CFScript regions inside
<cfscript> and </cfscript> tags. No other CFML tags
are allowed inside a
cfscript region. The following lines show a minimal script:
<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. This includes all common scope variables, 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. As in all ColdFusion expressions, you must use CFML
operators, such as LT, GT, and EQ. You cannot use JavaScript operators, such as <, >, ==, or ++.
For information about CFML expressions, operators, and functions, see Chapter 4, “Using
Expressions and Number Signs,” on page 75.
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 braces to group multiple statements together into one logical statement unit.
Unless otherwise indicated, you can use any ColdFusion expression in the body of a statement.
Note: This chapter documents all statements except function, var, and return. For information on
these statements, see Chapter 9, “Defining functions in CFScript,” on page 173.
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