244
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 <
expressions, but not CFML tags, inside a CFScript region.
CFScript example
The following example shows how you can rewrite a block of
Using CFML tags
<cfset employee=structnew()>
<cfoutput>
</cfoutput>
Using CFScript
<cfscript>
</cfscript>
The
can call this function anywhere within a page, it is most useful inside a
block. For information on the
Supported statements
CFScript supports the following statements:
if-else
for
for-in
return (in custom functions only)
<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>
About to add #Form.firstname# #Form.lastname#<br>
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);
function appends text to the page output stream. Although you
WriteOutput
Chapter 13 Extending ColdFusion Pages with CFML Scripting
> and <
cfscript
/cfscript
function, see the CFML Reference.
WriteOutput
while
break
switch-case
> tags. You can use ColdFusion
tags in CFScript:
cfset
cfscript
do-while
continue
var (in custom functions only)
Need help?
Do you have a question about the COLDFUSION 5-DEVELOPING and is the answer not in the manual?
Questions and answers