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/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble
Ticket application
http://www.houseoffusion.com/banners/view.cfm?bannerid=48
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:210928
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