House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

<cfscript> loop versus <cfloop>

  << Previous Post |  RSS |  Tree View |  Sort Oldest First |  Subscribe to this Group Next >> 

<cfscript> loop versus <cfloop>

I spent 5-6 hours trying to find the solution to this problem on my own. Jason Durham 04/15/2008 10:03 AM
didnt think of doing that :) Richard White 04/15/2008 10:02 AM
> That was it!!  Thanks a bunch! Dominic Watson 04/15/2008 09:58 AM
Oh good catch Dominic! Patrick Santora 04/15/2008 09:58 AM
That was it!!  Thanks a bunch! Jason Durham 04/15/2008 09:55 AM
Could it be that qNav is not var scoped? i.e. Dominic Watson 04/15/2008 09:49 AM
I'll have to check again to be 100% sure, but I believe the value is "". Jason Durham 04/15/2008 09:46 AM
I would check to see what the argument value for CHILDID is prior to using Patrick Santora 04/15/2008 09:44 AM
The variable used in the cfloop is an "i",  Outlook changed the case Jason Durham 04/15/2008 09:38 AM
I thought that too, but after copying the code from the thread and pasting Patrick Santora 04/15/2008 09:34 AM
just an observation but the index in the <cfloop> doesnt look like an 'i' Richard White 04/15/2008 09:31 AM
> The version with <cfloop> is the one that's giving me trouble. Dominic Watson 04/15/2008 09:29 AM
The syntax looks correct, what is the error you are getting? Patrick Santora 04/15/2008 09:29 AM
Provided that i is set to 1 before the for loop (var i = 1;), then yes, the Bobby Hartsfield 04/15/2008 09:29 AM
Thank you Dominic and Patrick for your suggestions.  In both cases, Jason Durham 04/15/2008 09:21 AM
you need to declare "i" via the script approach. cfloop does a basic Patrick Santora 04/15/2008 09:17 AM
> I'm having a hard time tracking down the source of an error I'm Dominic Watson 04/15/2008 09:16 AM
I'm having a hard time tracking down the source of an error I'm Jason Durham 04/15/2008 09:07 AM

04/15/2008 10:03 AM
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 -----
04/15/2008 10:02 AM
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 -----
04/15/2008 09:58 AM
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
04/15/2008 09:58 AM
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 -----
04/15/2008 09:55 AM
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
04/15/2008 09:49 AM
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
04/15/2008 09:46 AM
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 -----
04/15/2008 09:44 AM
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 -----
04/15/2008 09:38 AM
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 -----
04/15/2008 09:34 AM
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!!!
04/15/2008 09:31 AM
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!!!
04/15/2008 09:29 AM
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
04/15/2008 09:29 AM
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 -----
04/15/2008 09:29 AM
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) {                 ......... }
04/15/2008 09:21 AM
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 -----
04/15/2008 09:17 AM
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 -----
04/15/2008 09:16 AM
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
04/15/2008 09:07 AM
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) {                 ......... }
<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

May 24, 2012

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
     1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31     

Designer, Developer and mobile workflow conference