User Guide

Table Of Contents
40 Chapter 2: Elements of CFML
Built-in function names, such as Now or Hash
Scope names, such as Form or Session
Any name starting with cf. However, when you call a CFML custom tag directly, you prefix the
custom tag page name with cf_.
Operators, such as NE or IS
The names of any built-in data structures, such as Error or File
The names of any built-in variables, such as RecordCount or CGI variable names
CFScript language element names such as for, default, or continue
You must also not create form field names ending in any of the following, except to specify a form
field validation rule using a hidden form field name. (For more information on form field
validation, see Chapter 26, “Introduction to Retrieving and Formatting Data,” on page 609.)
_integer
_float
_range
_date
_time
_eurodate
Remember that ColdFusion is not case-sensitive. For example, all of the following are reserved
words: IS, Is, iS, and is.
CFScript
CFScript is a language within a language. CFScript is a scripting language that is similar to
JavaScript but is simpler to use. Also, unlike JavaScript, CFScript only runs on the ColdFusion
server; it does not run on the client system. A CFScript script can use all ColdFusion functions
and all ColdFusion variables that are available in the script’s scope.
CFScript provides a compact and efficient way to write ColdFusion logic. Typical uses of
CFScript include:
Simplifying and speeding variable setting
Building compact flow control structures
Encapsulating business logic in user-defined functions
The following sample script populates an array and locates the first array entry that starts with the
word “key”. It shows several of the elements of CFScript, including setting variables, loop
structures, script code blocks, and function calls. Also, the code uses a
cfoutput tag to display its
results. Although you can use CFScript for output, the
cfoutput tag is usually easier to use.
<cfscript>
strings = ArrayNew(1);
strings[1]="the";
strings[2]="key to our";
strings[4]="idea";
for( i=1 ; i LE 4 ; i = i+1 )