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

Search cf-talk

July 04, 2009

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

Home / Groups / ColdFusion Talk (CF-Talk)

cfscript for in vs cfloop collection

Author:
Jon Hall
07/15/2002 04:15 PM

"for-in loop: for (variable in collection) statement ; Note that variable can be any ColdFusion identifier, and collection must be the name of an existing ColdFusion structure. for (x in mystruct) mystruct[x]=0;" http://www.macromedia.com/v1/cfdocs/Advanced_ColdFusion_Development/08_Using _CFML_Scripting/adv08_2.htm Although I can do what you suggest, I'd prefer not to in this case. It's really looking like for-in loops are limited to CF structures only unlike cfloop. Anyone know for sure? jon > Yep... the for loop expects a counter (for (i = 1; i le Len(somevar); i = i > + 1) ) There is no "in" key word for it.  sorry.  You will have to determine > the number of childnodes in /trackresponse/activity and use that as your > counter. > > mark > > Perhaps someone else can see what I am doing wrong here (cf5). I've had this > problem in the past, and just included the code inline with a cfloop around > my cfscript, but now I want to convert the code to a UDF... > Here is the code. > > This works fine: > <cfloop collection="#transDOM.selectNodes("/TrackResponse/Activity")#" > item="i"> > > This throws an invalid parser construct error at the second parentheses (yes > I have tried both single and double quotes): > for ( i in objXMLDOM.selectNodes('/TrackResponse/Activity')) { > > Am I wrong in assuming that cfloop-collection and cfscript for-in loops are > the same? > > jon > > >


Mailing Lists