<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=CFScript</id>
	<title>CFScript - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=CFScript"/>
	<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=CFScript&amp;action=history"/>
	<updated>2026-10-25T23:32:35Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=CFScript&amp;diff=3822510&amp;oldid=prev</id>
		<title>imported&gt;SimLibrarian: rm contraction</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=CFScript&amp;diff=3822510&amp;oldid=prev"/>
		<updated>2024-10-16T22:45:36Z</updated>

		<summary type="html">&lt;p&gt;rm contraction&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{More citations needed|date =November 2006}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;CFScript&amp;#039;&amp;#039;&amp;#039; is an extension of [[ColdFusion Markup Language|CFML]] on the ColdFusion platform. CFScript resembles [[JavaScript]]. Some ColdFusion [[Software Developers|developers]] prefer it since it has less visual and typographical overhead than ordinary CFML.{{Clarify|reason=|date=March 2020}}&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
Unless it is within a pure script-based ColdFusion Component, all CFScript code must be contained within a CFScript tag pair as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cfm&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;cfscript&amp;gt;&lt;br /&gt;
xParam = 115;&lt;br /&gt;
yParam = 200;&lt;br /&gt;
color = &amp;#039;FFCC99&amp;#039;;&lt;br /&gt;
&amp;lt;/cfscript&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A simple example of a [[Subroutine|function]]:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cfm&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;cfscript&amp;gt;&lt;br /&gt;
function Sum(a, b) {&lt;br /&gt;
    var sum = a + b;&lt;br /&gt;
    return sum;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/cfscript&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A simple example of a component in CFScript, containing two functions:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
component {&lt;br /&gt;
    public void function foo() {&lt;br /&gt;
        WriteOutput(&amp;quot;Method foo() called&amp;lt;br/&amp;gt;&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public function getString() {&lt;br /&gt;
        var x = &amp;quot;hello&amp;quot;;&lt;br /&gt;
        return x;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ColdFusion 11, [[Railo]] 4.1+, and [[Lucee]] 4.5+ both do their best to fully support cf tags in CFScript.&lt;br /&gt;
While there may not be direct substitutions for all tags, it is often still possible to achieve the results of a tag in script, but via a different syntax. For example, this is how to get a query into a variable in CFSCRIPT without writing a [[User-defined function|UDF]]:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cfm&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;cfscript&amp;gt;&lt;br /&gt;
qGetData = new Query();&lt;br /&gt;
qGetData.setDataSource(&amp;#039;#Application.datasource#&amp;#039;);&lt;br /&gt;
qGetData.setSQL(&amp;#039;SELECT column1, column2 FROM table WHERE 1&amp;#039;);&lt;br /&gt;
qDateResult = qGetData.Execute().getResult();&lt;br /&gt;
&amp;lt;/cfscript&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Syntax ==&lt;br /&gt;
&lt;br /&gt;
Since ColdFusion 8, CFScript has supported [[Syntax (programming languages)|syntax]] abbreviations that are common in many other programming languages, such as &amp;quot;++&amp;quot;, &amp;quot;&amp;lt;=&amp;quot; and &amp;quot;+=&amp;quot;.&amp;lt;ref&amp;gt;{{Cite web|url=https://www.bennadel.com/blog/741-learning-coldfusion-8-all-hail-the-new-operator.htm|title=Learning ColdFusion 8: All Hail The New ++ Operator|last=Nadel|first=Ben|date=May 31, 2007|website=|archive-url=|archive-date=|access-date=}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic operators ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Operator !! Description&lt;br /&gt;
|-&lt;br /&gt;
| + - * / || Basic arithmetic: Addition, subtraction, multiplication, and division.&lt;br /&gt;
&lt;br /&gt;
In division, the right operand cannot be zero.&lt;br /&gt;
|-&lt;br /&gt;
| ++ -- || Increment and decrement. Increase or decrease the variable by one.&lt;br /&gt;
&lt;br /&gt;
These operators can be used for pre-incrementing or decrementing (as in x = ++ i), where the variable is changed before it is used in the expression. They can also be used for post-incrementing or decrementing (as in x = i++), where the value is changed after it is used in the expression. If the value of the variable i is initially 7, for example, the value of x in x = ++i is 8 after expression evaluation, but in x=i++, the value of x is 7. In both cases, the value of i becomes 8.&lt;br /&gt;
&lt;br /&gt;
These operators cannot be used with expressions that involve functions, as in f().a++. Also, you can use an expression such as -++x, but ---x and +++x cause errors, because their meanings are ambiguous. You can use parentheses to group the operators, as in -(--x) or +(++x), however.&lt;br /&gt;
|-&lt;br /&gt;
| += -= *= /= %= || Compound assignment operators. The variable on the right is used as both an element in the expression and the result variable. Thus, the expression a += b is equivalent to a = a +b.&lt;br /&gt;
&lt;br /&gt;
An expression can have only one compound assignment operator.&lt;br /&gt;
|-&lt;br /&gt;
| + - || Unary arithmetic: Set the sign of a number.&lt;br /&gt;
|-&lt;br /&gt;
| MOD or % || Modulus: Return the remainder after a number is divided by a divisor. The result has the same sign as the divisor. The value to the right of the operator should be an integer; using a non-numeric value causes an error, and if you specify a real number, ColdFusion ignores the fractional part (for example, 11 MOD 4.7 is 3).&lt;br /&gt;
|-&lt;br /&gt;
| \|| Integer division: Divide an integer by another integer. The result is also an integer; for example, 9\4 is 2. The right operand cannot be zero&lt;br /&gt;
|-&lt;br /&gt;
| ^|| Exponentiation: Return the result of a number raised to a power (exponent). Use the caret character (^) to separate the number from the power; for example, 2^3 is 8. Real and negative numbers are allowed for both the base and the exponent. However, any expression that equates to an imaginary number, such -1^.5 results in the string &amp;quot;-1.#IND. ColdFusion does not support imaginary or complex numbers.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Comments ===&lt;br /&gt;
CFScript has two forms of comments: single line and multiline.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// This is a single-line comment.&lt;br /&gt;
// This is a second single-line comment.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
/* This is a multiline comment.&lt;br /&gt;
   You do not need to start each line with a comment indicator.&lt;br /&gt;
   This line is the last line in the comment. */&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Try / catch ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
try {&lt;br /&gt;
    throw(message=&amp;quot;Oops&amp;quot;, detail=&amp;quot;xyz&amp;quot;);&lt;br /&gt;
} catch (any e) {&lt;br /&gt;
    WriteOutput(&amp;quot;Error: &amp;quot; &amp;amp; e.message);&lt;br /&gt;
    rethrow;&lt;br /&gt;
} finally {&lt;br /&gt;
    WriteOutput(&amp;quot;I run even if no error&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Switch statement ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
switch (car) {&lt;br /&gt;
    case &amp;quot;Nissan&amp;quot;:&lt;br /&gt;
         WriteOutput(&amp;quot;I own a Nissan&amp;quot;);&lt;br /&gt;
         break;&lt;br /&gt;
    case &amp;quot;Toyota&amp;quot;:&lt;br /&gt;
         WriteOutput(&amp;quot;I own a Toyota&amp;quot;);&lt;br /&gt;
         break;&lt;br /&gt;
    default:&lt;br /&gt;
         WriteOutput(&amp;quot;I&amp;#039;m exotic&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Looping ===&lt;br /&gt;
&lt;br /&gt;
==== For loop ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
for (i=1; i &amp;lt;= ArrayLen(array); i=i+1) {&lt;br /&gt;
    WriteOutput(array[i]);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== FOR IN Loop ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
struct = StructNew();&lt;br /&gt;
struct.one = &amp;quot;1&amp;quot;;&lt;br /&gt;
struct.two = &amp;quot;2&amp;quot;;&lt;br /&gt;
for (key in struct) {&lt;br /&gt;
    WriteOutput(key);&lt;br /&gt;
}&lt;br /&gt;
//OUTPUTS onetwo&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== While loop ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
x = 0;&lt;br /&gt;
while (x &amp;lt; 5) {&lt;br /&gt;
    x = x + 1;&lt;br /&gt;
    WriteOutput(x);&lt;br /&gt;
}&lt;br /&gt;
// Outputs: 12345&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Do / while loop ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
x = 0;&lt;br /&gt;
do {&lt;br /&gt;
    x = x + 1;&lt;br /&gt;
    WriteOutput(x);&lt;br /&gt;
} while (x &amp;lt;= 0);&lt;br /&gt;
// Outputs: 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Looping over an array ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
for (item in array) {&lt;br /&gt;
    doSomething(item);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Differences from JavaScript ==&lt;br /&gt;
Although CFScript and JavaScript are similar, they have several key differences. The following list identifies CFScript features that differ from JavaScript:&lt;br /&gt;
&lt;br /&gt;
* CFScript uses ColdFusion [[Expression (computer science)|expression]], which are not a superset or a subset of JavaScript expressions. In particular, ColdFusion expressions do not support [[Bitwise operation|bitwise operators]], and the ColdFusion MOD or % operator operates differently from the corresponding JavaScript % operator: In ColdFusion, the operator does integer arithmetic and ignores fractional parts. ColdFusion expressions also support the EQV, IMP, CONTAINS, and DOES NOT CONTAIN operators that are not supported in JavaScript.&lt;br /&gt;
*[[Variable declaration|Variable declarations]] (var keyword) are only used in user-defined functions and threads.&lt;br /&gt;
* CFScript is not case sensitive.&lt;br /&gt;
* All statements end with a semicolon, and line breaks in the code are ignored.&lt;br /&gt;
* Assignments are statements, not expressions, and therefore cannot be used in situations that require evaluating the assignment operation.&lt;br /&gt;
* JavaScript objects, such as &amp;lt;code&amp;gt;window&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;document&amp;lt;/code&amp;gt;, are not available.&lt;br /&gt;
* Only the ColdFusion server processes CFScript. There is no client-side CFScript.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
{{Reflist}}&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* [http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7feb.html Extending ColdFusion Pages with CFML Scripting - Adobe]&lt;br /&gt;
* [https://helpx.adobe.com/coldfusion/developing-applications/the-cfml-programming-language/extending-coldfusion-pages-with-cfml-scripting.html]&lt;br /&gt;
&lt;br /&gt;
{{DEFAULTSORT:Cfscript}}&lt;br /&gt;
[[Category:CFML programming language]]&lt;br /&gt;
[[Category:Scripting languages]]&lt;/div&gt;</summary>
		<author><name>imported&gt;SimLibrarian</name></author>
	</entry>
</feed>