User Guide

Table Of Contents
128 Chapter 6: Extending ColdFusion Pages with CFML Scripting
For example, the following example loops through a query in CFScript:
...
<cfscript>
// Loop through the qGetEmails RecordSet
for (x = 1; x LTE qGetEmails.RecordCount; x=x+1) {
This_id = qGetEmails.Emails_id[x];
This_Subject = qGetEmails.Subject[x];
This_RecFrom = qGetEmails.RecFrom[x];
This_SentTo = qGetEmails.SentTo[x];
This_dReceived = qGetEmails.dReceived[x];
This_Body = qGetEmails.Body[x];
... // More code goes here.
}
</cfscript>
Using CFScript statements
The following sections describe how to use these CFScript statements:
Using assignment statements and functions
Using conditional processing statements
Using looping statements
Using assignment statements and functions
CFScript assignment statements are the equivalent of the
cfset tag. These statements have the
following form:
lval = expression;
lval is any ColdFusion variable reference; for example:
x = "positive";
y = x;
a[3]=5;
structure.member=10;
ArrayCopy=myArray;
You can use ColdFusion function calls, including UDFs, directly in CFScript. For example, the
following line is a valid CFScript statement:
StructInsert(employee,"lastname",FORM.lastname);
cftry, cfcatch try and catch statements
cfcookie Direct assignment of Cookie scope memory-only variables. You cannot
use direct assignment to set persistent cookies that are stored on the
user’s system.
cfobject CreateObject function
Tag CFScript equivalent