It's the way index-based loops work. At the first pass of the <cfloop>, the
INDEX variable is created with the initial value, and the condition (in
this case the condition is an implicit "index variable value <= TO value").
If the condition is true, the loop block is entered. At the bottom of the
loop block, execution is returned to the top of the block, the index
variable is incremented by the STEP value (the default being 1), then the
condition is evaluated again. If the condition is met, we're back into the
loop block; if not, processing skips down to the first statement after the
<cfloop /> block.

If you desk-check this, you will see that on the last iteration of the
loop, the index value will be incremented beyond the bounds of the TO
value, making the loop exit. So its final value will always - intrinsically
- be higher than the TO value, by the amount of the STEP value.

It's just how these things work.

-- 
Adam


On 1 March 2013 00:46, funand learning <funandlrnn...@gmail.com> wrote:

>
> I am sorry, I wasn't clear. the "to" is arraylen. Sometimes the arraylen is
> 1
>
> <cfloop from="1" to="#ArrayLen(somearray)# index="j">
>
> </cfloop>
>
> <cfoutput>#j#</cfoutput> ----------this returns 2
>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:354747
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to