House of Fusion
Home of the ColdFusion Community
Hostmysite Dedicated Hosting

Search cf-talk

July 19, 2008

<<   <   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     

Subscribe Now
Fusion Authority Quarterly Update - ColdFusion 8 Special Edition

For ColdFusion hosting try HostMySite.com.
Search over 2,500 ColdFusion resources here  >>>      
Home /  Groups /  ColdFusion Talk (CF-Talk)

<cfscript> loop versus <cfloop>

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Could it be that qNav is not var scoped? i.e.
Dominic Watson
04/15/08 09:49 A
That was it!! Thanks a bunch!
Jason Durham
04/15/08 09:55 A
> That was it!! Thanks a bunch!
Dominic Watson
04/15/08 09:58 A
Oh good catch Dominic!
Patrick Santora
04/15/08 09:58 A
didnt think of doing that :)
Richard White
04/15/08 10:02 A
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jason Durham
04/15/2008 09:07 AM

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) {                 ......... }

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dominic Watson
04/15/2008 09:16 AM

> 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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Patrick Santora
04/15/2008 09:17 AM

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 -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jason Durham
04/15/2008 09:21 AM

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, Jason Durham <jdurham@cti-stl.com> wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dominic Watson
04/15/2008 09:29 AM

> 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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Patrick Santora
04/15/2008 09:29 AM

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 -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jason Durham
04/15/2008 09:38 AM

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, Jason Durham <jdurham@cti-stl.com> wrote: > 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 -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Patrick Santora
04/15/2008 09:44 AM

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 -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jason Durham
04/15/2008 09:46 AM

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, Jason Durham <jdurham@cti-stl.com> wrote: > 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 -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dominic Watson
04/15/2008 09:49 AM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jason Durham
04/15/2008 09:55 AM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dominic Watson
04/15/2008 09:58 AM

> That was it!!  Thanks a bunch! Hoorah! No worries ;) D -- Blog it up: http://fusion.dominicwatson.co.uk

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Patrick Santora
04/15/2008 09:58 AM

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 -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jason Durham
04/15/2008 10:03 AM

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 -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Richard White
04/15/2008 09:31 AM

just an observation but the index in the <cfloop> doesnt look like an 'i' my eyes may be playing me up though!!!

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Patrick Santora
04/15/2008 09:34 AM

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". On Tue, Apr 15, 2008 at 6:32 AM, Richard White <richard@j7is.co.uk> wrote: > just an observation but the index in the <cfloop> doesnt look like an 'i' > > my eyes may be playing me up though!!!

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Bobby Hartsfield
04/15/2008 09:29 AM

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) {                 ......... }


<< Previous Thread Today's Threads Next Thread >>

Mailing Lists