The way I understand it, a <cfloop condition... > is right, but he needs the
<cfloop from="1" to="#totalMonths#" index="somethingAppropriate"> inside it.
<cfloop condition="p1 gt 0">
<cfloop from="1" to="#totalMonths#" index="somethingAppropriate">
</cfloop>
<cfset p1 = p1 - whatever> <!-- or inside the inner loop maybe?? -->
</cfloop>
-----Original Message-----
From: Eddie [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 29, 2005 4:19 PM
To: CF-Talk
Subject: Re: embedded loops, trouble with
On 6/29/05, mayo <[EMAIL PROTECTED]> wrote:
> I was asked to display financial calculations. It requires embedded
> loops and I've been spinning my wheels on this project.
>
> The first task is to keep going through a loop until one reaches an
> inputted number.
>
> EX: The mortgage will be paid off in [ 36 ] months.
>
> So the loop is
>
> <cfloop from="1" to="#totalMonths#" index="somethingAppropriate">
>
> </cfloop>
>
> Inside this loop there are several calculations. If at the end of
> #totalMonths# one of the calculations isn't equal to 0 (or another
> inputted number designated as p1) the loop has to be done again.
>
> So, inside loop (same as above)
>
> <cfloop from="1" to="#totalMonths#" index="somethingAppropriate">
>
> <cfset p1=p1-myIndex>
> .
> #p1#
> </cfloop>
>
> <cfif p1 GT "1" > // If p1 doesn't equal 0 do again.
>
> <cfloop from="1" to="#totalMonths#" index="somethingAppropriate">
>
> <cfset p1=p1-myIndex>
> .
> #p1#
> </cfloop>
>
> </cfif>
I think a "cfloop condition" is more appropriate in your situation
than "cfloop index". Something like this:
<cfset x = 36>
<cfloop condition="x gt 0" >
<cfoutput>#x#</cfoutput>
<cfset x = x - 1>
</cfloop>
You can add your calculation/condition inside the loop. Basically,
whenever x hits 0, the loop ends. So, if you do not make sure that x
will hit zero somehow, your loop will keep on looping until the end of
days. HTH.
--
Eddie.
http://awads.net/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:210929
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54