Am i missing something obvious.
cfoutput
cfset t = 1
cfloop condition=t LTE 10
t=#t#BR
cfset t++
cfif t GT 10
cfbreak/
/cfif
/cfloop
cfset w = 1
cfloop condition=1 eq 1
w=#w#BR
cfset w++
cfif w GT 10
cfbreak/
/cfif
/cfloop
cfloop from=1 to=10 index=y
y=#y#BR
cfset y++
/cfloop
cfscript
Looks like your incrementing X in the for statement and in the body of the
loop
On Thu, Apr 24, 2014 at 8:55 AM, Byron Mann byronos...@gmail.com wrote:
Am i missing something obvious.
cfoutput
cfset t = 1
cfloop condition=t LTE 10
t=#t#BR
cfset t++
cfif t GT 10
cfbreak/
/cfif
Yes, that last one with x is what I actually want.
I'm just surprise the first few versions do not act in the same manner.
Byron Mann
Lead Engineer Architect
HostMySite.com
On Thu, Apr 24, 2014 at 12:25 PM, Blake wdavi...@gmail.com wrote:
Looks like your incrementing X in the for
You are only incrementing the earlier loops by one.
Why not do something like
cfset y = y+2
On Thu, Apr 24, 2014 at 9:28 AM, Byron Mann byronos...@gmail.com wrote:
Yes, that last one with x is what I actually want.
I'm just surprise the first few versions do not act in the same manner.
cfloop from=1 to=10 index=x
#x#-
cfset x = x + 2
/cfloop
1- 2- 3- 4- 5- 6- 7- 8- 9- 10-
I would use step in cfloop, however, the increment can be variable from
iteration to iteration.
Byron Mann
Lead Engineer Architect
HostMySite.com
On Thu, Apr 24, 2014 at 12:32 PM, Blake
cfset t = 1
cfloop condition=t LTE 10
t=#t#BR
cfset t=t+2
cfif t GT 10
cfbreak/
/cfif
/cfloop
t=1
t=3
t=5
t=7
t=9
On Thu, Apr 24, 2014 at 9:39 AM, Byron Mann byronos...@gmail.com wrote:
cfloop from=1 to=10 index=x
#x#-
cfset x = x + 2
/cfloop
1- 2- 3- 4- 5- 6-
Am i missing something obvious.
[...]
Only the last version is working as I would expect. I ran into this
attempting to increment an index inside cfloop, so I could skip a few
records in an array.
It's difficult to say how your expectations are off, given you don't *seem* to
tell us what said
maybe this?
cfloop from=1 to=10 index=y
cfif NOT (y mod 2)
cfcontinue
/cfif
y=#y#BR
/cfloop
On Thu, Apr 24, 2014 at 9:49 AM, Adam Cameron dacc...@gmail.com wrote:
Am i missing something obvious.
[...]
Only the last version is working as I would expect. I ran into
Am i missing something obvious.
cfloop from=1 to=10 index=y
y=#y#BR
cfset y++
/cfloop
With this one, yes. With this sort of loop, CF maintains the counter
internally, and just exposes its current value each iteration. So you can do
what you like to the value inside the loop body, CF will
They are all working the way they are intended, but I will look at one in
particular as it can catch a lot of people out.
cfloop from=1 to=10 index=y
y=#y#BR
cfset y++
/cfloop
When ColdFusion does any looping like this, the y is reset to the actual
loop valuem hence making the manual increment
The problem with cfscript is that it is more ESMAC compliant, which means
you can increment it when being used in a for loop as you have shown in
your last example.
Well yes and no. the CFScript construct:
for(i=1; i=10;i++){
// stuff
}
is not analogous to:
cfloop index=i from=1
Yes Adam, you're right. I looked at the code quickly and saw the one
increment and assumed *sigh* that it was using the for loop in the first
example. Well in that case it is working as intended then.
Regards,
Andrew Scott
WebSite: http://www.andyscott.id.au/
Google+:
OK, me==dah, the first 2 examples I just need to increment by 2 (or any
other factor) other than 1. This is what happens without enough coffee.
My actual code in use was like the 3rd example, but it is nested inside
other loops. I had to break the inner loop in differing steps/increments.
13 matches
Mail list logo