if (thisRoll <> 0) and not(rollover(43) or rollover(44) or rollover(45) or rollover(46) or rollover(47) or rollover(48) or rollover(16) or rollover(17) or rollover(18) or rollover(19) or rollover(20) or rollover(21) or rollover(22) or rollover(23)) then
set totalOldPayments = totalOldPayments + tempPayment
set tempPayment = 0
set n = 5
else
set totalOldPayments = totalOldPayments + getAt(tempCCBalance,(getAt(ccOrder,n)))
set tempPayment = tempPayment - getAt(tempCCBalance,(getAt(ccOrder,n)))
if tempPayment <= 0 then
set tempPayment = 0
set n = 5
end if
setAt tempCCBalance, (getAt(ccOrder,n)), 0
setAt tempCCActive, (getAt(ccOrder,n)), 0
setAt ccOrder, n, 0
end if
end if
end repeat
--IF THERE'S STILL MONEY LEFT OVER, PUT IT IN ZERO-INTEREST SAVINGS
if tempPayment > 0 then
set tempSavings = tempSavings + tempPayment
end if
--IF THERE'S ENOUGH SAVINGS, PAY OFF OTHER LOANS
set n = 0
repeat while n < 5
set n = n + 1
if (getAt(tempLActive,n) <> 0) and (tempSavings >= (getAt(tempLBalance,n))) then
set totalOldPayments = totalOldPayments + (getAt(tempLBalance,n))
set tempSavings = tempSavings - (getAt(tempLBalance,n))
setAt tempLBalance, n, 0
setAt tempLActive, n, 0
end if
end repeat
end if
--FIGURE OUT IF WE'RE DONE
set n = 0
set alldone = TRUE
repeat while n < 5
set n = n + 1
if (getAt(tempCCActive,n) <> 0) or (getAt(tempLActive,n) <> 0) then
set alldone = FALSE
end if
end repeat
end repeat
set n = 0
set termBalance = 0
repeat while n < 5
set n = n + 1
if getAt(tempCCActive,n) <> 0 then
set termBalance = termBalance + getAt(tempCCBalance,n)
end if
if getAt(tempLActive,n) <> 0 then
set termBalance = termBalance + getAt(tempLBalance,n)
end if
end repeat
--FINALLY, FILL THE FIELDS ON THE LAST PAGE.
if alldone then
set oldTermText = tempMonths & "month"
if tempMonths <> 1 then
set oldTermText = oldTermText & "s"
end if
else
set oldTermText = "an infinite amount of time"
end if
if loanType = "homeequity" then
set tempLoanType = "home equity"
else
set tempLoanType = "personal"
end if
calcDollar string(payment), 0
set tempPaymentText = the result
calcDollar string(termBalance), 0
set termBalanceText = the result
set the text of member "totaltext" = "If you consolidate your debts into one " & tempLoanType & " loan (with an interest rate of " & the text of member "irate" & " and a monthly contribution of " & tempPaymentText & "), it will take you " & the text of member "term" & " to pay off all your debts."
calcDollar string(totalOldPayments), 0
set the text of member "remainingBefore" = termBalanceText
set the text of member "remainingAfter" = "$0"
calcDollar string(totalOldPayments), 0
set the text of member "incomeBefore" = the result
calcDollar string(totalNewPayments), 0
set the text of member "incomeAfter" = the result
calcDollar string(totalOldInterest), 0
set the text of member "interestBefore" = the result
calcDollar string(totalNewInterest), 0
set the text of member "interestAfter" = the result