About Cfscript; Cfscript Example; Supported Statements - MACROMEDIA COLDFUSION 4.5-DEVELOPING WEB Develop Manual

Developing web applications with coldfusion
Table of Contents

Advertisement

338

About CFScript

The ColdFusion server-side scripting language, CFScript, offers ColdFusion
functionality in script syntax.
This JavaScript-like language offers the same control flow, but without tags. CFScript
regions are bounded by <CFSCRIPT> and </CFSCRIPT>. You can use ColdFusion
expressions, but not CFML tags, inside a CFScript region.
See the CFML Language Reference for more information about CFML expressions.

CFScript example

The following example shows how a block of CFSET tags can be rewritten in CFScript:
Using CFML tags
<CFSET employee=StructNew()>
<CFSET employee.firstname=FORM.firstname>
<CFSET employee.lastname=FORM.lastname>
<CFSET employee.email=FORM.email>
<CFSET employee.phone=FORM.phone>
<CFSET employee.department=FORM.department>
<CFOUTPUT>About to add #FORM.firstname# #FORM.lastname#
</CFOUTPUT>
Using CFScript
<CFSCRIPT>
employee=StructNew();
employee.firstname=FORM.firstname;
employee.lastname=FORM.lastname;
employee.email=FORM.email;
employee.phone=FORM.phone;
employee.department=FORM.department;
WriteOutput("About to add " & FORM.firstname & " " &
FORM.lastname);
</CFSCRIPT>
The WriteOutput function appends text to the page output stream. Although you can
call this function anywhere within a page, it is most useful inside a CFSCRIPT block.
See the CFML Language Reference for information on the WriteOutput function.

Supported statements

CFScript supports the following statements:
if-else
while
do-while
Developing Web Applications with ColdFusion

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION 4.5-DEVELOPING WEB and is the answer not in the manual?

This manual is also suitable for:

Coldfusion 4.5

Table of Contents