cfscript tag

CFScript is a language within a language. CFScript is a scripting language that is similar to JavaScript but is simpler to use. Also, unlike JavaScript, CFScript only runs on the ColdFusion server; it does not run on the client system. A CFScript script can use all ColdFusion functions and all ColdFusion variables that are available in the script's scope.
CFScript provides a compact and efficient way to write ColdFusion logic. Typical uses of CFScript include:

  • Simplifying and speeding variable setting
  • Building compact flow control structures
  • Encapsulating business logic in user-defined functions
    The following sample script populates an array and locates the first array entry that starts with the word "key". It shows several of the elements of CFScript, including setting variables, loop structures, script code blocks, and function calls. Also, the code uses a cfoutput tag to display its results. Although you can use CFScript for output, the cfoutput tag is often easier to use.
<cfscript> 
strings = ArrayNew(1); 
strings[1]="the"; 
strings[2]="key to our"; 
strings[4]="idea"; 
for( i=1 ; i LE 4 ; i = i+1 ) 
{ 
 if(Find("key",strings[i],1)) 
  break; } 
</cfscript> 
<cfoutput>Entry #i# starts with "key"</cfoutput><br>

You use CFScript to create user-defined functions. 
For more information on CFScript, see Extending ColdFusion Pages with CFML Scripting. For more information on user-defined functions, see Writing and Calling User-Defined Functions.

 Adobe

Get help faster and easier

New user?

Adobe MAX 2024

Adobe MAX
The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX

The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX 2024

Adobe MAX
The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX

The Creativity Conference

Oct 14–16 Miami Beach and online