Chapter 13. CFScript


Because ColdFusion is a tag-based markup language, most web developers should find it relatively easy to pick up. However, developers accustomed to procedural and scripting languages often find ColdFusion's syntax ambiguous, overly simplified, or insufficient when it comes to complex or lengthy logical statements. The creators of ColdFusion realized this and tried to surmount it with the introduction of CFScript in ColdFusion 4.1. CFScript provides a method for developers who are more comfortable using scripting-based languages, such as JavaScript, to exploit their knowledge and skill. CFScript, until recently, was also the only way to create user-defined functions (UDFs). In fact, many of the examples in this chapter will be in either standard ColdFusion Markup Language (CFML) or CFScript, so the following section provides a short primer of sorts to familiarize the reader with CFScript.

CFScript can be used to set variables, loop through collections, and work with the many ColdFusion functions and expressions. One will often find that CFScript enables the author to write much clearer logic, as well as more succinct code in specific instances. Although we cannot show every instance in which CFScript should be used instead of CFML, we will provide some rules of thumb. The most important rule of thumb is to use the syntax with which you are most productive. All other considerations come after that!

CFScript is based on ECMA Script, which is essentially JavaScript, so anyone comfortable with JavaScript will find CFScript easy to learn. The European Computer Manufacturers Association (ECMA) is a European-based industry association that strives to standardize information and communication systems.


For more information about ECMA Script, go to

Inside ColdFusion MX
Inside Coldfusion MX
ISBN: 0735713049
EAN: 2147483647
Year: 2005
Pages: 579 © 2008-2017.
If you may any questions please contact us: