1 COMMON A, AL, B, BASEONLY, C, C$, C1, CAT$, CC, CKT$, D, D$, DD, DIA, DIMN$, DMS, E, EO, EX$, F, F$, FD, FF, FQ, FRQ, G$, GO$, I, I$, L, LATLONG, LD, LL, LN, LS, LW, LX, MAX, MENU, MIN, MX, N, NN, NT, OV, P, PI, PROG$, Q, QQ, QU, R, RA, RC, T, T$, U, U$, UH, UL$, V$, VC, W, WHIP, WIRD, WW, X, X$, X1, XS, Z$, ZP, ZS
10 ' SUNUP - 29 SEP 86 rev. 23 NOV 03. 'excerpted from PATHFIND.BAS
20 CLS:KEY OFF
30 
40 COLOR 7,0,0
50 IF EX$=""THEN EX$="EXIT"
60 DIM M$(12),D(12),D$(12)
70 AM$="##:## am":AZ$=" ###.#ø":PM$="##:## pm":EL$=" ##.#ø"
80 P$="##.##":P1$="####":P2$="##.#
90 UL$=STRING$(80,205)
100 PI=4*ATN(1)
110 DR=PI/180:RD=180/PI         'DEG to RAD, RAD to DEG
120 '
130 CLS
140 PRINT "SUNUP/SUNDOWN";TAB(57);;"by George Murphy VE3ERP";
150 PRINT UL$;
160 PRINT "Press number in ( ) to:"
170 PRINT " (1)  Run program"
180 PRINT " (0)  Exit"
190 Z$=INKEY$:IF Z$=""THEN 190
200 IF Z$="0"THEN CLS:CHAIN EX$
210 IF Z$="1"THEN 230 ELSE 190
220 GOTO 190
230 VIEW PRINT 3 TO 24:CLS:VIEW PRINT:LOCATE 3
240 LINE INPUT "Name of your location.......? ";N$
250 INPUT "ENTER: Your latitude  (XX.X degrees, minus if SOUTH).....";LX
260 OO=LX:GOSUB 1600
270 INPUT "ENTER: Your longitude (XX.X degrees, minus if EAST)......";LO
280 OO=LO:GOSUB 1600
290 LA=LX*DR     'Latitude in Radians
300 LN=CSRLIN:PRINT "Press number in ( ) to indicate your Time Zone:"
310 PRINT " (1) Atlantic";
320 PRINT " (2) Eastern";
330 PRINT " (3) Central";
340 PRINT " (4) Mountain";
350 PRINT " (5) Pacific";
360 PRINT " (6) Other";
370 Z$=INKEY$:IF VAL(Z$)>=1 AND VAL(Z$)<=6 THEN 380 ELSE 370
380 IF Z$="1"THEN SX=60:SX$="AST"
390 IF Z$="2"THEN SX=75:SX$="EST"
400 IF Z$="3"THEN SX=90:SX$="CST"
410 IF Z$="4"THEN SX=105:SX$="MST"
420 IF Z$="5"THEN SX=120:SX$="PST"
430 IF Z$="6"THEN SX=INT(LO/15)*15:SX$="Local"
440 VIEW PRINT LN TO 24:CLS:VIEW PRINT:LOCATE LN
450 MX=LO-SX                                'Deg. correction for std. meridian
460 MC=MX/15                                'Hrs. correction for std. meridian
470 MR=MX*DR                                'Rad equiv. of meridian correction
480 INPUT "ENTER: Year to be used in calculations (yyyy)............";YR
490 OO=YR:GOSUB 1600:GOSUB 1600:Z=(YR/100-INT(YR/100))*10
500 Y=INT(Z):X=(Z-Y)*10:W=(Y+X)/4:W=INT(W*1.000000E+05+5.000000E-01)/1.000000E+05
510 IF INT(W)=W THEN Q1=29:DA=366 ELSE Q1=28:DA=3.652423E+02
520 DATA JAN,31,FEB,0,MAR,31,APR,30,MAY,31,JUN,30
530 DATA JUL,31,AUG,31,SEP,30,OCT,31,NOV,30,DEC,31
540 FOR Z=1 TO 12:READ M$(Z),D$(Z):D(Z)=VAL(D$(Z)):NEXT Z:RESTORE:D(2)=Q1
550 K=360/DA                                'Days to degrees
560 '
570 N1=0:N2=0:N3=0:N4=0:YZ=1
580 PRINT "ENTER: First date? (No. of Month, Day)...................";
590 INPUT M1,D1:GOSUB 1570:MO1=M1
600 N1=NQ
610 PRINT "ENTER: Last date?  (No. of Month, Day)...................";
620 INPUT M1,D1:GOSUB 1570:MO2=M1
630 N2=NQ:IF N2<N1 THEN N2=365+N2
640 '
650 '.....sunrise/sunset
660 INPUT "ENTER: Increment in days.................................";X1
670 IF X1=0 THEN X1=1
680 CLS
690 LOCATE 1,1
700 PRINT TAB(14);"Hours";TAB(24);"Sunrise (";SX$;;")";
710 PRINT TAB(45);"Sunset (";SX$;;")";TAB(65);;"Elev.& Azimuth"
720 PRINT TAB(14);"of";
730 PRINT TAB(24);"and Azimuth";TAB(45);"and Azimuth";TAB(66);"of Noon Sun"
740 PRINT "   Date";TAB(14);"Daylight";TAB(24);" (degrees)";
750 PRINT TAB(45);" (degrees)";TAB(66);" (degrees)"
760 PRINT UL$;
770 VIEW PRINT 5 TO 23:CLS:VIEW PRINT:LOCATE 5
780 GOSUB 1660
790 LN=4
800 FOR N=N1 TO N2 STEP X1
810 LN=LN+1
820 GOSUB 1320
830 CC=PI/2                 '90 degrees at sunrise, sunset
840 IF LA-Z<0 THEN T=(ED-MG+MX+5.000000E-01)ELSE  T=(180-ED-MG-MX-5.000000E-01)
850 IF T<0 THEN T=360+T
860 AA=CC-Z
870 BB=CC-LA
880 SS=(AA+BB+CC)/2
890 TT=(SIN(SS-AA)*SIN(SS-BB)*SIN(SS-CC))/SIN(SS)
900 IF TT<0 THEN TT=0
910 TR=SQR(TT)
920 C1=TR/SIN(SS-CC)
930 C=2*ATN(C1)*RD                'Angle in degrees
940 AZ=2*RD*ATN(TR/SIN(SS-AA))    'Azimuth in degrees
950 CH=C/15                       'Hours vs. C
960 '.....sunrise
970 R=12-5.600000E-02+ET+MC-CH:H1    =R   'Sunrise
980 R$=STR$(INT(R)):RL=LEN(R$)-1
990 RH$=RIGHT$((R$),RL)           'sunrise decimal hour
1000 IF VAL(RH$)<10 THEN RH$="0"+RH$
1010 M=INT((R-INT(R))*60)
1020 RM$=STR$(M):ML=LEN(RM$)-1
1030 RM$=RIGHT$((RM$),ML)          'sunrise decimal minute
1040 IF VAL(RM$)<10 THEN RM$="0"+RM$
1050 RT$=RH$+":"+RM$               'sunrisetime
1060 '.....sunset
1070 S=12+5.600000E-02+ET+MC+CH:H2=S  'Sunset
1080 S$=STR$(INT(S)):SL=LEN(S$)-1
1090 SH$=RIGHT$((S$),SL)           'sunset decimal hour
1100 IF VAL(SH$)<10 THEN SH$="0"+SH$
1110 M=INT((S-INT(S))*60)
1120 SM$=STR$(M):ML=LEN(SM$)-1
1130 SM$=RIGHT$((SM$),ML)          'sunset decimal minute
1140 IF VAL(SM$)<10 THEN SM$="0"+SM$
1150 ST$=SH$+":"+SM$               'sunset time
1160 IF LA-Z<0 THEN AL=FIX(90-(Z-LA)*RD-5.000000E-01)ELSE AL=(90-(LA-Z)*RD-5.000000E-01)
1170 GOSUB 1460
1180 RISE=AZ-MG-5.000000E-01
1190 SET=360-AZ-MG-5.000000E-01
1200 PRINT TAB(15);USING "##.#";S-R; 'SD-SU;
1210 PRINT TAB(24);RT$; ;" @";        ' USING AM$;SU,MU;:PRINT " @";
1220 PRINT USING AZ$;RISE;
1230 PRINT TAB(45);ST$;;" @";
1240 PRINT USING AZ$;(360-AZ-MG-5.000000E-01);
1250 PRINT TAB(65);USING "##.###ø";AL;
1260 PRINT "  ";USING  "###.#ø";T;
1270 IF LN<24 THEN PRINT "";:GOTO 1290
1280 GOSUB 1770:CLS:LN=0
1290 NEXT N
1300 GOTO 1740   'end
1310 '
1320 '.....compute long.of GP SUN & EQ TIME
1330 NN=N:IF N>365 THEN NN=N-365
1340 L1=(2.795750E+02+(K*NN))*DR
1350 G1=(3.569670E+02+(K*NN))*DR
1360 LD=L1+(1.916000*SIN(G1)+1.999999E-02*SIN(2*G1))*DR
1370 DL=3.978199E-01*SIN(LD)
1380 Z=ATN(DL/SQR(-DL*DL+1))
1390 EL=-1.046999E+02*SIN(L1)+5.962000E+02*SIN(2*L1)+4.300000*SIN(3*L1)-1.269999E+01
1400 EL=EL*SIN(4*L1)-4.292999E+02*COS(L1)-2*COS(2*L1)+1.929999E+01*COS(3*L1)
1410 ET=-EL/3600
1420 ED=ET*15
1430 ER=ED*DR
1440 RETURN
1450 '
1460 '.....print month and day
1470 NN=N:IF N>365 THEN NN=N-365
1480 Q1=0:FOR Q=1 TO 12:Q2=Q1:Q1=Q1+D(Q):IF NN<=Q1 THEN 1500
1490 NEXT Q
1500 PRINT M$(Q);;" ";
1510 A=NN-Q2:A$=STR$(A):M=LEN(A$)-1
1520 A$=RIGHT$((A$),M)
1530 IF VAL(A$)<10 THEN A$="0"+A$
1540 PRINT A$;;"/";YR$(YZ);
1550 RETURN
1560 '
1570 '.....convert date to day of year
1580 Q1=0:FOR Q=1 TO M1:Q2=Q1:Q1=Q1+D(Q):NEXT Q:NQ=Q2+D1:RETURN
1590 '
1600 '......subsequent years
1610 Y$(1)=STR$(YR):Y$(2)=STR$(YR+1)
1620 IF MO1=MO2 THEN Y$(2)=Y$(1)
1630 FOR Q=1 TO 2:YR$(Q)=RIGHT$(Y$(Q),2):NEXT Q
1640 RETURN
1650 '
1660 VIEW PRINT:LOCATE 4,1
1670 IF LX>0 THEN LX$="øN."ELSE LX$="øS."
1680 IF LO>0 THEN LO$="øW."ELSE LO$="øE."
1690 LOCATE ,13:PRINT "µat ";N$;" (";STR$(ABS(LX));LX$;STR$(ABS(LO));LO$;")ÆÍ"
1700 LOCATE CSRLIN-1,64:PRINT " EL "
1710 LOCATE CSRLIN-1,74:PRINT " AZ "
1720 RETURN
1730 '
1740 '.....end
1750 GOSUB 1770:GOTO 130
1760 '
1770 '.....PRT
1780 KEY OFF:GOSUB 1850:LOCATE 25,5:COLOR 0,2
1790 PRINT " Send this page to:(1)Printer Queue? (2)Printout? ";
1800 PRINT "(3)Next page? (1/2/3)";:COLOR 7,0
1810 Z$=INKEY$:IF Z$<"1"OR Z$>"3"THEN 1810 ELSE GOSUB 1850
1820 IF Z$="3"THEN RETURN
1830 FOR I%=1 TO 24:FOR J%=1 TO 80:LPRINT CHR$(SCREEN(I%,J%));:NEXT J%:NEXT I%
1840 IF Z$="2"THEN LPRINT CHR$(12) ELSE 1780
1850 LOCATE 25,1:PRINT STRING$(80,32);:RETURN
