CFScript: Difference between revisions

Content deleted Content added
m remove uncited claim
m rm contraction
Tags: Mobile edit Mobile app edit iOS app edit App section source
 
(2 intermediate revisions by 2 users not shown)
Line 4:
 
== Usage ==
Unless it's is within a pure script-based ColdFusion Component, all CFScript code must be contained within a CFScript tag pair as follows:
<syntaxhighlight lang="cfm">
<cfscript>
xParam = 115;
yParam = 200;
color = 'FFCC99';
</cfscript>
</syntaxhighlight>
Line 41:
<syntaxhighlight lang="cfm">
<cfscript>
qGetData = new Query();
qGetData .setDataSource('#APPLICATIONApplication.datasource#');
qGetData .setSQL('SELECT column1, column2 FROM table WHERE 1');
qDateResult = qGetData .Execute().getResult();
</cfscript>
</syntaxhighlight>
Line 93:
</syntaxhighlight>
 
=== Try / Catchcatch ===
<syntaxhighlight lang="javascript">
try {
Line 121:
=== Looping ===
 
==== For Looploop ====
<syntaxhighlight lang="javascript">
for (i=1; i LTE<= ArrayLen(array); i=i+1) {
WriteOutput(array[i]);
}
Line 139:
</syntaxhighlight>
 
==== While Looploop ====
<syntaxhighlight lang="javascript">
x = 0;
while (x LT< 5) {
x = x + 1;
WriteOutput(x);
Line 149:
</syntaxhighlight>
 
==== Do / Whilewhile Looploop ====
<syntaxhighlight lang="javascript">
x = 0;
do {
x = x + 1;
WriteOutput(x);
} while (x LTE<= 0);
// Outputs: 1
</syntaxhighlight>
 
==== Looping over an Arrayarray ====
<syntaxhighlight lang="javascript">
for (item in array) {