|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
<cfscript> loop versus <cfloop>
Author: Jason Durham
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56031#303416
I spent 5-6 hours trying to find the solution to this problem on my own.
*embarrassed*
I *hope* not to make that mistake again! Var first... ask questions
later. :)
Oh good catch Dominic!
On Tue, Apr 15, 2008 at 6:50 AM, Dominic Watson <
watson.dominic@googlemail.com> wrote:
----- Excess quoted text cut - see Original Post for more -----
Author: Richard White
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56031#303415
didnt think of doing that :)
----- Excess quoted text cut - see Original Post for more -----
Author: Dominic Watson
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56031#303413
> That was it!! Thanks a bunch!
Hoorah! No worries ;)
D
--
Blog it up: http://fusion.dominicwatson.co.uk
Author: Patrick Santora
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56031#303414
Oh good catch Dominic!
On Tue, Apr 15, 2008 at 6:50 AM, Dominic Watson <
watson.dominic@googlemail.com> wrote:
----- Excess quoted text cut - see Original Post for more -----
Author: Jason Durham
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56031#303412
That was it!! Thanks a bunch!
Could it be that qNav is not var scoped? i.e.
<cfset qNav = getSubs(ARGUMENTS.ParentID) />
If this a recursive function, that should break it.
Dominic
--
Blog it up: http://fusion.dominicwatson.co.uk
Author: Dominic Watson
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56031#303411
Could it be that qNav is not var scoped? i.e.
<cfset qNav = getSubs(ARGUMENTS.ParentID) />
If this a recursive function, that should break it.
Dominic
--
Blog it up: http://fusion.dominicwatson.co.uk
Author: Jason Durham
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56031#303410
I'll have to check again to be 100% sure, but I believe the value is "".
I would check to see what the argument value for CHILDID is prior to
using
getDepth and make sure it is numeric. Your answer might be there.
I believe the variable you want to verify is
"qNav[getChildOfField()][i]".
On Tue, Apr 15, 2008 at 6:39 AM, Jas
> The variable used in the cfloop is an "i", Outlook changed the case
of
----- Excess quoted text cut - see Original Post for more -----
scoped
----- Excess quoted text cut - see Original Post for more -----
Author: Patrick Santora
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56031#303409
I would check to see what the argument value for CHILDID is prior to using
getDepth and make sure it is numeric. Your answer might be there.
I believe the variable you want to verify is "qNav[getChildOfField()][i]".
On Tue, Apr 15, 2008 at 6:39 AM, Jas
----- Excess quoted text cut - see Original Post for more -----
Author: Jason Durham
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56031#303406
The variable used in the cfloop is an "i", Outlook changed the case of
it automagically.
Here is a copy of the function using cfscript syntax that works
flawlessly (written by Matt Quackenbush)...
http://cfm.pastebin.com/d7595c18e
Here is a copy of my re-write using <cfloop>...
http://cfm.pastebin.com/m24328359
The error the <cfloop> version results in....
The CHILDID argument passed to the getDepth function is not of type
numeric.
I've verified that the function works for several iterations but fails
on the 4th or 5th time through. They are both using the same external
methods [getDepth(),getParent(),getSubs()].
The syntax looks correct, what is the error you are getting?
On Tue, Apr 15, 2008 at 6:22 AM, Jas
> Thank you Dominic and Patrick for your suggestions. In both cases,
"i"
> is var scoped just before the loops.
>
> The version with <cfloop> is the one that's giving me trouble.
Perhaps
> it's not in the loop syntax. I've gone character by character
comparing
> the rest of the code in each function and they appear identical.
>
> you need to declare "i" via the script approach. cfloop does a basic
> declaration for you. the for loop does not.
>
> NOTE: if this loop is within a cffunction then ensure you have scoped
i
----- Excess quoted text cut - see Original Post for more -----
Author: Patrick Santora
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56031#303405
I thought that too, but after copying the code from the thread and pasting
it into my local environment showed it is being a capital "i".
> just an observation but the index in the <cfloop> doesnt look like an
'i'
>
> my eyes may be playing me up
though!!!
Author: Richard White
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56031#303404
just an observation but the index in the <cfloop> doesnt look like an 'i'
my eyes may be playing me up though!!!
Author: Dominic Watson
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56031#303401
> The version with <cfloop> is the one that's giving me trouble.
Is that an 'L' for the cfloop index or an uppercase 'i'? Other than that I'd
say we'd need to see more (nothing wrong with the cfloop or scripted loop if
i is set before it).
Dominic
--
Blog it up: http://fusion.dominicwatson.co.uk
Author: Patrick Santora
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56031#303402
The syntax looks correct, what is the error you are getting?
On Tue, Apr 15, 2008 at 6:22 AM, Jas
----- Excess quoted text cut - see Original Post for more -----
Author: Bobby Hartsfield
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56031#303403
Provided that i is set to 1 before the for loop (var i = 1;), then yes, the
loops are identical
.:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com
http://cf4em.com
I'm having a hard time tracking down the source of an error I'm
receiving from a recursive function. Are these loops identical?
<cfloop from="1" to="#qNav.recordCount#" index="I">
........
</cfloop>
for (; i LTE qNav.recordCount; i=i+1) {
.........
}
Author: Jason Durham
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56031#303399
Thank you Dominic and Patrick for your suggestions. In both cases, "i"
is var scoped just before the loops.
The version with <cfloop> is the one that's giving me trouble. Perhaps
it's not in the loop syntax. I've gone character by character comparing
the rest of the code in each function and they appear identical.
you need to declare "i" via the script approach. cfloop does a basic
declaration for you. the for loop does not.
NOTE: if this loop is within a cffunction then ensure you have scoped i
correctly (place "var i = 1" above the loop)
or (i = 1; i LTE qNav.recordCount; i=i+1) {
.........
}
-Pat
http://patweb99.avatu.com
On Tue, Apr 15, 2008 at 6:08 AM, Jas
----- Excess quoted text cut - see Original Post for more -----
Author: Patrick Santora
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56031#303398
you need to declare "i" via the script approach. cfloop does a basic
declaration for you. the for loop does not.
NOTE: if this loop is within a cffunction then ensure you have scoped i
correctly (place "var i = 1" above the loop)
or (i = 1; i LTE qNav.recordCount; i=i+1) {
.........
}
-Pat
http://patweb99.avatu.com
On Tue, Apr 15, 2008 at 6:08 AM, Jas
----- Excess quoted text cut - see Original Post for more -----
Author: Dominic Watson
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56031#303396
> I'm having a hard time tracking down the source of an error I'm
> receiving from a recursive function. Are these loops identical?
Not quite, the cfscript loop should look like this:
for (i=1; i LTE qNav.recordCount; i=i+1) {
.........
}
Dominic
--
Blog it up: http://fusion.dominicwatson.co.uk
Author: Jason Durham
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:56031#303394
I'm having a hard time tracking down the source of an error I'm
receiving from a recursive function. Are these loops identical?
<cfloop from="1" to="#qNav.recordCount#" index="I">
........
</cfloop>
for (; i LTE qNav.recordCount; i=i+1) {
.........
}
|
May 24, 2012
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||