No actually I appreciate you helping me out. I’ve been trying to cross that threshold into thinking advanced CF, but like you said – it’s a different thought process. What’s difficult is putting the advanced theory into practice in one own app. Examples in books are always so generic. I really get caught up with – is there a better way to do it, and you’ve identified one. I’m going to try that out. Thanks, again Adaryl.

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Adaryl Wakefield
Sent: Thursday, September 25, 2003 9:27 PM
To: [EMAIL PROTECTED]
Subject: Re: [KCFusion] CFLOOP Issue

 

The array idea is just a diffence in thought process. When I started learning CF I was taught to separate logic and presentation as much a possible so i would have tossed everything in the loop above the opening <html> tag and I would have stored the count of instances in an array like  

<cfset headlinePerSection = ArrayNew(1)>

<cfloop index="i" from="1" to="3">

      <cfset headlinePerSection[i] = ListValueCount(countSections, i)>

</cfloop>

 

Then futher down in the presentation layer of things I would have had another loop tag that spit out the (in this case) three values. Like I said..just a differnt(and probaly longer) way of doing it.

A.

----- Original Message -----

Sent: Thursday, September 25, 2003 9:09 PM

Subject: RE: [KCFusion] CFLOOP Issue

 

Uh, I just moved the </cfloop> tag below the cfoutput block, and it worked like a charm. This probably seemed fairly elementary and simple – but you know when you work on a getting over a series of hurdles for three days and you start missing the obvious as you near the last hurdle? That’s where I am. Happy to get to move on now.

 

My curiosity has me wondering what you mean by:  Why not put an array in the loop so you could store the value each interation? I never considered that and don’t really know what you mean. If you think that is a better solution, I’d like to hear about how that works.

 

Thanks Adaryl

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Adaryl Wakefield
Sent: Thursday, September 25, 2003 8:27 PM
To: [EMAIL PROTECTED]
Subject: Re: [KCFusion] CFLOOP Issue

 

Umm..maybe im not quite getting something in your question but..your cfoutput is outside the loop tags. Since that is the case then headlinePerSection keeps getting reassigned a new value each loop 4 then 5 then 6. Why not put an array in the loop so you could store the value each interation?

A.

----- Original Message -----

Sent: Thursday, September 25, 2003 6:48 PM

Subject: [KCFusion] CFLOOP Issue

 

I have a list (valuelist) that I get from a query. Looks like this: 1,1,1,1,2,2,2,2,2,3,3,3,3,3,3

 

I need an integer for how many 1’s, 2’s, 3’s, etc there are in the list. 4-1’s, 5-2’s, and 6-3’s.

 

I understand that ListValueCount(list, value) does that. It is supposed to report how many instances of a value there are in a list. So I am trying to loop through it. But I don’t think my loop is looping. When I cfoutput the index value for the loop, I get 4. It’s like it skips over 1,2, and outputs only 3. Here’s the code which if you copy and paste into Dreamweaver or whatever you use to code, you can run. I hard coded the variables:

 

<cfset maxSection = 3>

<cfset countSections = "1,1,1,1,2,2,2,2,2,3,3,3,3,3,3">

<cfloop index="i" from="1" to="3">

      <cfset headlinePerSection = ListValueCount(countSections, i)>

      <cfset columnOneCount = Int(headlinePerSection/2)>

      <cfset columnTwoCount = Ceiling(headlinePerSection - columnOneCount)>

</cfloop>

<cfoutput>

i: #i#<br />

maxSection: #maxSection#<br />

countSections: #countSections#<br />

headlinePerSection:#headlinePerSection#<br />

columnOneCount: #columnOneCount#<br />

columnTwoCount: #columnTwoCount#<br /><br />

</cfoutput>

 

The test output looks like this:

 

i: 4
maxSection: 3
countSections: 1,1,1,1,2,2,2,2,2,3,3,3,3,3,3
headlinePerSection:6
columnOneCount: 3
columnTwoCount: 3

 

Again, I need an integer for how many 1’s, 2’s, 3’s, etc there are in the list. 4 -1’s, 5-2’s, and 6-3’s.

 

Got any ideas?

 

Jim T. Pickering

913/269-3339

 

Reply via email to