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:
CFScript operator
|
CFML operator
|
CFScript operator
|
CFML operator
|
---|
==
|
EQ
|
!=
|
NEQ
|
<
|
LT
|
<=
|
LTE
|
>
|
GT
|
>=
|
GTE
|
For information about CFML expressions, operators, and functions, see Using Expressions and Number Signs.
Statements
CFScript supports the following statements:
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
|
|
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.