There are a couple of nice statements you can use to control processing within loops, namely
- break
- continue
Break is of course used to exit the current loop entirely and resume page processing from the first CF statement after the end loop tag. Lovely!
Continue has a subtle but handy difference, it ends the current loop iteration and ‘continues’ from the beginning of the next loop iteration. Very lovely
Now the problem is that there is no ColdFusion tag equivalent for continue, it’s only accessible when in a <cfscript> block. As far as I know this is the only statement in the CFML language which is available in <cfscript> but not tags
For some scenarios this will be ok, especially for the cfscripters out there. But for people who don’t like (for several reasons) <cfscript> then this is a limitation which I hope Adobe will address (among others!) in Scorpio.
And don’t forget that the inherent limitations of <cfscript> (limited cftag support) means that sometimes you won’t be able to do your logic in cfscript. For example you may want to use a <cfsavecontent> etc which you can’t do in <cfscript>.
I know…I know that you can create your own functions simulating tag functionality in cfscript but all gets a little messy doesn’t it?
Related Pages
- No related posts
cfcontinue has not been implemented in the current release of Scorpio. I just added a request for enhancement (#65487) for it.
Cheers.
Rob Gonda
November 29th, 2006
I find the solution that is in the first comment of this page: http://weblogs.macromedia.com/cantrell/archives/2003/08/living_without.cfm
a useful workaround in the meantime, but it is far from elegant.
Ryan Guill
November 29th, 2006
Ah yes Ryan that would work splendidly! Nice one!
This number will never be 5: #i#
sharmo
November 30th, 2006