# 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
- for
- break
- continue
- for-in
- switch-case

### For more information

The following JavaScript references may be useful in understanding the concepts and control flow statements in CFScript:

- Netscape's JavaScript Guide
- Netscape's JavaScript Reference
- David Flanagan's JavaScript: The Definitive Guide, published by O'Reilly & Associates, 1996, 1998, http://www.oreilly.com.