home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
551-575
/
apd558
/
amoner2
/
loancalc.amos
/
loancalc.amosSourceCode
Wrap
AMOS Source Code
|
1993-11-29
|
5KB
|
239 lines
Set Buffer 30
Fix(2)
On Error Proc BOOBOO
Rem defeat Intital output window
INIT:
Dim SCH#(600,3)
Global SCH#()
STATUSLINE=21
Def Fn PMT#(L#,M,I#)=L#/((1.0-(1.0+I#)^-M)/I#)
T1$="The Loan Calculator"
T2$="Presented by: Admiralty Software Engineering"
T3$="This AMOS port was brought to you by The AMONER Project"
Screen Open 0,640,200,16,Hires
Wind Open 1,0,0,78,24,1
Title Top "The Loan Calculator Created by: Ira S. Davis �1985-1991"
Title Bottom "Ported from HiSoft BASIC to AMOS by Michael Cox"
TXT=4
MSG=9
OLDNMBRS=5
NEWNMBRS=6
Palette 0,0,,0,,,,,,$FF0
MAIN:
Pen TXT
Clw
Curs Off
Centre T1$
Cmove ,2
Centre T2$
SETVALUES
Locate 1,5
Pen TXT
Print "Amount of Loan"
Locate 32,5
Pen OLDNMBRS
Print AMT#
Locate 31,5
Curs On
Input AMT#
Locate 1,6
Pen TXT
Print "Annual Percentage Rate (APR)"
Locate 32,6
Pen OLDNMBRS
Print APR#
Locate 31,6
Input APR#
Locate 1,7
Pen TXT
Print "Term of Loan (Years)"
Locate 32,7
Pen OLDNMBRS
Print YRS
Locate 31,7
Input YRS
SETVALUES
Locate 1,9
Pen TXT
Curs Off
Set Tab 15
Print "Loan Amt";Tab$;
Set Tab 30 : Print "APR";Tab$;"Term";
Set Tab 45 : Print Tab$;"Payments"
PAY#= Fn PMT#(L#,M,I#)
Pen OLDNMBRS
Print AMT#
Locate 15,10
Print Using "##.# %";APR#
Locate 30,10
Print Using "## Yrs";YRS
Locate 45,10
Pen NEWNMBRS
Print Using "$######.##";PAY#
Locate 1,12
Pen TXT
Set Tab 30
Print "Total Payback";Tab$;"Interest Paid"
Pen NEWNMBRS
Print Using "$######.##";PAY#*M
Locate 30,13
Print Using "$######.##";(PAY#*M)-AMT#
Locate 1,STATUSLINE : Centre Space$(40)
Pen MSG
Curs Off
Centre "View Loan Amortization Schedule? Y/N"
A$=""
While(A$<>"Y") and(A$<>"N")
A$=Upper$(Inkey$)
Wend
Curs Off
If A$="Y"
AMORTIZE
End If
Locate 1,STATUSLINE
Pen MSG
Centre Space$(40) : Locate 1,STATUSLINE
Centre "Calculate Another Loan? Y/N"
A$=""
While(A$<>"Y") and(A$<>"N")
A$=Upper$(Inkey$)
Wend
If A$="N"
Locate 1,STATUSLINE
Centre Space$(40)
Pen TXT
Locate 1,STATUSLINE
Centre T3$
Wait 250
Wind Close
Screen Close 0
Run "autoexec.amos"
Else
Goto MAIN
End If
Procedure AMORTIZE
Shared PAY#,YRS,M,STATUSLINE,TXT,OLDNMBRS,NEWNMBRS,MSG
Clw
Pen TXT
Set Tab 36
Print "Amortization Schedule for Year";Tab$;"of ";
Pen OLDNMBRS
Print YRS
Locate 50,1
Pen TXT
Print "Payments = "
Locate 61,1
Pen OLDNMBRS
Print Using "$######.##";PAY#
CALCSCHEDULE
Locate 1,3
Pen TXT
Set Tab 15
Print "Month";Tab$;"Interest";
Set Tab 30 : Print Tab$;"Principle";
Set Tab 45 : Print Tab$;"Balance"
For X=1 To YRS
PTOTAL#=0
ITOTAL#=0
Locate 32,0
Pen NEWNMBRS
Print Using "###";X
For Y=1 To 12
NDX=((X-1)*12)+Y
Locate 1,Y+4
Pen OLDNMBRS
Print Y
Locate 15,Y+4
Print Using "$######.##";SCH#(NDX,1)
Locate 30,Y+4
Print Using "$######.##";SCH#(NDX,2)
Locate 45,Y+4
Print Using "$######.##";SCH#(NDX,3)
ITOTAL#=ITOTAL#+SCH#(NDX,1)
PTOTAL#=PTOTAL#+SCH#(NDX,2)
Next Y
Locate 1,Y+5
Pen TXT
Print "YTD Totals"
Locate 15,Y+5
Pen NEWNMBRS
Print Using "$######.##";ITOTAL#
Locate 30,Y+5
Print Using "$######.##";PTOTAL#
If NDX=M
Locate 1,Y+6
Pen TXT
Print "Final Payment is"
FINAL#=SCH#(M,1)+SCH#(M,2)
Locate 30,Y+6
Pen NEWNMBRS
Print Using "$######.##";FINAL#
End If
Locate 1,STATUSLINE
Pen MSG
Centre "Any key to continue"
Wait Key
Locate 1,STATUSLINE
Centre Space$(40)
Next X
End Proc
Procedure CALCSCHEDULE
Shared M,AMT#,I#,PAY#
BALANCE#=AMT#
For NDX=1 To M-1
SCH#(NDX,1)=I#*BALANCE#
SCH#(NDX,2)=PAY#-SCH#(NDX,1)
BALANCE#=BALANCE#-SCH#(NDX,2)
SCH#(NDX,3)=BALANCE#
Next
SCH#(M,1)=SCH#(M-1,3)*I#
SCH#(M,2)=SCH#(M-1,3)
SCH#(M,3)=0
End Proc
Procedure SETVALUES
Shared AMT#,L#,APR#,I#,YRS,M
If AMT#<>0
L#=AMT#
End If
If L#=0
L#=1000.0
AMT#=1000.0
End If
If AMT#=0.0
AMT#=L#
End If
If APR#<>0.0
I#=APR#/1200.0
End If
If I#=0.0
I#=12.0/1200.0
APR#=12.0
End If
If APR#=0.0
APR#=I#*1200.0
End If
If YRS<>0
M=YRS*12
End If
If M=0
M=12
YRS=1
End If
If YRS=0
YRS=M/12
End If
End Proc
Procedure BOOBOO
Clw
E=Errn
If E=9
Centre "Control-C Pressed. . . Exiting. . ."
Wait 150
Run "autoexec.amos"
End If
Centre "Error Number "+Str$(E)+" encountered"
Cdown : Centre "Please report this to Michael Cox"
Cdown : Centre "See Doc/Amoner002.Doc for contact info"
Wait 250
Run "autoexec.amos"
End Proc