Adobe COLDFUSION 9 Manual page 41

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
The CFML Programming Language
<cfset myArray = ArrayNew(1)>
<!--- Use ArraySet to initialize the first ten elements to 123 --->
<cfset ArraySet(myArray, 1, 10, 123)>
<cfset myArray[4] = "kumquats">
<cfset foundit = False>
<cfset i = 0>
<cfloop condition = "(NOT foundit) AND (i LT ArrayLen(myArray))">
<cfset i = i + 1>
<cfif myArray[i] IS "kumquats">
<cfset foundit = True>
</cfif>
</cfloop>
<cfoutput>
i is #i#<br>
foundit is #foundit#<br>
</cfoutput>
Note: You can get an infinite conditional loop if you do not force an end condition. In this example, the loop is infinite if
you omit the
<cfset i = i + 1>
cfbreak
The
tag exits the
cfbreak
cfloop
The following example shows the use of a
<cfloop query="fruitOrder">
<cfif fruit IS "kumquat">
<cfoutput>You cannot order kumquats!<br></cfoutput>
<cfbreak>
</cfif>
<cfoutput>You have ordered #quantity# #fruit#.<br></cfoutput>
</cfloop>
cfabort and cfexit
The
tag stops processing of the current page at the location of the
cfabort
user or calling tag everything that was processed before the
to display. You can use the
cfabort
an error, occurs.
The
tag controls the processing of a custom tag, and can only be used in ColdFusion custom tags. For more
cfexit
information see,
"Terminating tag
Character case
ColdFusion is not case sensitive. For example, the following all represent the
However, get in the habit of consistently using the same case rules in your programs; for example:
cfsEt.
• Develop consistent rules for case use, and stick to them. If you use lowercase characters for some tag names, use
them for all tag names.
• Always use the same case for a variable. For example, do not use both myvariable and MyVariable to represent the
same variable on a page.
Follow these rules to prevent errors on application pages where you use both CFML and case-sensitive languages,
such as JavaScript.
statement. To end an infinite loop, stop the ColdFusion application server.
tag. You typically use it in a
cfif
tag in a query loop:
cfbreak
cfabort
tag as the body of a
tag to stop processing a page when a condition, typically
cfif
execution" on page 219 and the CFML Reference.
Last updated 8/5/2010
tag to exit the loop if a particular condition occurs.
tag. ColdFusion returns to the
cfabort
tag. You can optionally specify an error message
tag:
,
cfset
cfset
CFSET
36
,
, and even
CFSet

Advertisement

Table of Contents
loading

Table of Contents