Skip navigation.

<CFSCRIPT> part 1

What is <CFSCRIPT> and why should I use it? Well, this tag has been around since version 4. If you are familiar with scripting languages such as JavaScript, you may find it easier to write much of your ColdFusion code in a similar syntax.

There are 3 types of coding that may be used inside the <CFSCRIPT> and <\CFSCRIPT> tags.
1. Instead of the <CFSET> tag you assign a value to a variable, use cfscript.
2. For flow control use <CFSCRIPT> instead of <CFIF> or <CFSWITCH> tags.
3. Statements using ColdFusion functions or User Defined Functions UDFs.

For this post, I'll look at the use of <CFSCRIPT> for assigning values to simple variables.

Example 1.1


user_id = "ssinger";
first_name = "Sam";
last_name = "Singer";


Easy! Notice that a semicolon (;) is needed after each line of code.

To comment your code use the single line marker, double forward slash (//). If you want to comment multiple lines, use the forward slash followed by the asterisk (/*) as the opening marker and the asterick followed by the forward slash (*/) as the closing marker.

Example 1.2


/*This code is
commented out.*/

// So is this.


The next post will address using <CFSCRIPT> for flow control.