January 18, 2007

Can ColdFusion "continue"?

Believe it or not, ColdFusion does not support “continue” (nor tag: “cfcontinue”).

This script demonstrates one of possible ways how you can simulate “continue” behavior:

<cfloop from="1" to="10" index="i">
<cftry>
<cfif>
<cfthrow type="continue">
<cfelse>
#i#
</cfif>
<cfcatch type="continue">
<!--- ignore --->
</cfcatch>
</cftry>
</cfloop>


Reference:
http://weblogs.macromedia.com/cantrell/archives/2003/08/living_without.cfm

Update:
Since 5th October 2009, day when CF9 has been released, developer can, finally, cfcontinue ;) Hooray. Ah, yes, "lupus in fabula", Adobe introduce cffinally as well.

2 comments:

Unknown said...

Actually ColdFusion does support continue, starting with ColdFusion 9.

Jason Dean said...

Actually, ColdFusion has supported continue for a while, in cfscript. The tag was just added in CF9.

Here are the docs for CF7 that shows continue can be used in a loop in cfscript. I am not sure if it existed in 6 or before, I didn't feel like taking the time to look.

https://www.adobe.com/livedocs/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=00000970.htm