CFScript
Encyclopedia
CFScript is an extension of CFML
ColdFusion Markup Language
ColdFusion Markup Language, more commonly known as CFML, is a scripting language for web development that runs on the JVM, the .NET framework, and Google App Engine...

 on the ColdFusion platform. CFScript resembles JavaScript
JavaScript
JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....

. Some ColdFusion developers prefer it since it has less visual and typographical overhead than ordinary CFML; only the actual changes are represented in the code (whereas normal CFML would involve CFSET tags at every line).

Usage

All CFScript code must be contained within a CFScript tag pair, as follows:


xParam = 115;
yParam = 200;
color = 'FFCC99';



While many ColdFusion tags have exact CFScript analogies, there are quite a few tags that do not. These include both complex tags that would be difficult to duplicate and simple tags that are easy to imitate (using ColdFusion UDF's):

Complex:






Simple:





While there may not be direct substitutions for all tags, it is often still possible to achieve the results of a tag in script, but via a different syntax. For example this is how to get a query into a variable in CFSCRIPT without writing a UDF:

qGetData = new Query;
qGetData .setDataSource('#APPLICATION.datasource#');
qGetData .setSQL('SELECT column1, column2 FROM table WHERE 1');
qDateResult = qGetData .Execute.getResult;

Syntax

Since Coldfusion 8 cfscript has supported syntax abbreviations that are common in many other programming languages, such as "++", "<=" and "+=".
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK