5MODE0
10REM MOON: Program adapted by D. Amb
rose from that given in
20REM Microsoft QuickBasic 4.5 in Cha
pter 1 of
30REM Numerical Recipes in Basic by J
. C. Sprott, CUP 1991
40REM Initial month (IM%), initial da
y (ID%) and year (IY%) are
50REM entered in line 140. Program th
en calculates table.
100DIM phase$(4)
110phase$(1)="new moon":phase$(2)="fir
st quarter"
120phase$(3)="full moon":phase$(4)="la
st quarter"
130tzone=0:VDU15
140IM%=1:ID%=7:IY%=1996
150PRINT"Date of the next few phases o
f the moon"
160PRINT
170timzon=-tzone/24
180N%=INT(12.37*(IY%-1900+(IM%-.5)/12)
)
190nphase%=2
200PROCjulday(IM%,ID%,IY%)
210J1%=JD%
220PROCflmoon(N%,nphase%)
230N%=INT(N%+(J1%-JD%)/28)
240REM N% is approximate no. of full m
oons since january 1900
250PRINT" Date
Time(EST) phase"
260PRINT" day month yea
r hr min"
270PRINT
280FOR J%=1 TO 20
290PROCflmoon(N%,nphase%)
300ifrac%=INT(24*(frac+timzon))
310min%=INT((24*(frac+timzon)-ifrac%)*
60)
330IF ifrac%<0 JD%=JD%-1:ifrac%=ifrac%
+24
340IF ifrac%>=12 JD%=JD%+1:ifrac%=ifra
c%-12 ELSE ifrac%=ifrac%+12
350PROCcaldat(JD%)
360PRINT OD%,OM%,OY%,ifrac%,min%;
370PRINT" "phase$(nphase%+1)
380IF nphase%=3 nphase%=0:N%=N%+1 ELSE
nphase%=nphase%+1
390NEXT J%
400VDU14:END
410
1000DEF PROCflmoon(N%,nphase%)
1010C=N%+nphase%/4
1020T=C/1236.85
1030T2=T^2
1040AQ=359.2242+29.105366*C:REM You are
n't really intended to understand
1050AM=306.0253+385.816918*C+.01073*T2:
REM this algorithm but it works
1060JD%=2415020+28*N%+7*nphase%
1070xtra=.75933+1.53058868*C+(.0001178-
1.55E-7*T)*T2
1080IF nphase%=0 OR nphase%=2 xtra=xtra
+(.1734-.000393*T)*SIN(RAD(AQ))-.4068*SI
N(RAD(AM))
1090IF nphase%=1 OR nphase%=3 xtra=xtra
+(.1721-.0004*T)*SIN(RAD(AQ))-.628*SIN(R
AD(AM))
1100IF xtra>=0 I%=INT(xtra) ELSE I%=INT
(xtra-1)
1110JD%=JD%+I%
1120frac=xtra-I%
1130ENDPROC
1140
1150DEF PROCjulday(MM%,ID%,IY%)
1160igreg%=588829
1170IF IY%<0 IY%=IY%+1
1180IF MM%>2 JY%=IY%:JM%=MM%+1:ELSE JY%
=IY%-1:JM%=MM%+13
1190JD%=INT(365.25*JY%)+INT(30.6001*JM%
)+ID%+1720995
1200IF ID%+31*(MM%+12*IY%)>=igreg% JA%=
INT(.01*JY%):JD%=JD%+2-JA%+INT(.25*JA%)
1210ENDPROC
1220
1230DEF PROCcaldat(JD%)
1240igreg%=2299161
1250IF JD%>=igreg% jalpha%=INT(((JD%-18
67216)-.25)/36524.25): JA%=JD%+1+jalpha%
-INT(.25*jalpha%) ELSE JA%=JD%
1260JB%=JA%+1524
1270JC%=INT(6680+((JB%-2439870)-122.1)/
365.25)
1280JD%=365*JC%+INT(.25*JC%)
1290JE%=INT((JB%-JD%)/30.6001)
1300OD%=JB%-JD%-INT(30.6001*JE%)
1310OM%=JE%-1
1320IF OM%>12 OM%=OM%-12
1330OY%=JC%-4715
1340IF OM%>2 OY%=OY%-1
1350IF OY%<=0 OY%=OY%-1
1360ENDPROC
1370
1380DEF FNN="MOON"