Sure. But you *don't need to*. <cfloop> deals with it. -- Adam
On 1 March 2013 12:38, Russ Michaels <[email protected]> wrote: > > Also it is quite easy to test if the dynamic.value will be above zero. > > E.g > > <Cfif arraylen(var) gt 0> > Do loop > <cfelse> > Do something else > </cfif> > > Regards > Russ Michaels > www.michaels.me.uk > www.cfmldeveloper.com - Free CFML hosting for developers > www.cfsearch.com - CF search engine > On Mar 1, 2013 12:26 PM, "Adam Cameron" <[email protected]> > wrote: > > > > > On 1 March 2013 08:37, Russ Michaels <[email protected]> wrote: > > > > > > > > The.simple answer is, only use an index loop where there is more than 1 > > > iteration. It will always run once even if the loop is 0, because it > has > > to > > > run once to find that out. > > > > > > > Nah, the condition is checked, but the code within the loop is not run > even > > once if the condition is not met: > > > > <cfoutput> > > Before<br> > > <cfloop index="i" from="1" to="0"> > > Within: #i#<br> > > </cfloop> > > After #i#<br> > > </cfoutput> > > > > Output: > > Before > > After 1 > > > > As per the OP's situation, if the TO value is dynamic, one doesn't always > > know whether the loop will run zero, one or more times. So to say one > > should only use a loop when there's more than one iteration is a bit > > unreasonable. Anyway, the looping construct works fine no matter what > > combination of FROM/TO values you give it, so as long as you know how the > > thing works, it's safe to use it however one wants to. > > > > -- > > Adam > > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:354757 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

