My fault for not explaining myself well -- I understand what my client
wants to do but I'm not a financial analyst so I'm not able to describe
it well.
What needs to be done is more than simply find "0," it is to arrive at
"0" at the end of the loop. Dummy me, but I haven't looked to see if
there are any CFCs that do exactly this.
-- gil
My code is below.
<cfset P1="#P1#">
<cfset payment="#payment#">
<cfset R="#rate#">
<cfset I=P1*R/12>
<cfset Prin=payment-I>
<cfset P2=P1-Prin>
<table border cellpadding="3">
<tr>
<th>P1</th>
<th>R</th>
<th>I</th>
<th>Prin</th>
</tr>
<cfloop condition="p1 gt 0">
<cfloop from="1" to="360" index="myIndex">
<cfset p1=p1-myIndex>
<tr>
<td>#numberFormat(P1,"9,999.99")#</td>
<td>#numberFormat(R,"9,999.99")#</td>
<td>#numberFormat(I,"9,999.99")#</td>
<td>#numberFormat(Prin,"9,999.99")#</td>
<td>#numberFormat(p1,"9,999.99")#</td>
</tr>
<cfset p1 = p1 - 1>
</cfloop>
</cfloop>
</table>
</cfoutput>
-----Original Message-----
From: Dave Francis [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 29, 2005 4:43 PM
To: CF-Talk
Subject: RE: embedded loops, trouble with
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:210939
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