Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Jun 2013 10:16:52 -0700
From:      Chris Maness <chris@chrismaness.com>
To:        "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   Any BASIC Gurus around?
Message-ID:  <CANnsUMG-2yaGgY-_aXtt2UTTRPCGFgFzhE0_sF74++saw5Uy1g@mail.gmail.com>

Next in thread | Raw E-Mail | Index | Archive | Help
I am having trouble getting this old USNO basic program running in bwBASIC.
 The error output is not clear to me where the problem is.  Here is the
code, if someone wouldn't mind running it and suggesting edits:

10 DEF FNARCOS(ARG)=3D1.570796-ATN(ARG/SQR(1.-ARG*ARG))
20 DEF FNARCSIN(ARG)=3DATN(ARG/SQR(1.-ARG*ARG))
30 DEF FNDEG(ARG)=3DINT(ARG)+((ARG-INT(ARG))*1O.)/6.
40 DEF FNDMS(ARG)=3DINT(ARG)+6. * (ARG - INT(ARG)) / 10!
50 RD=3D57.29578
60 DR=3D1./RD
70 DIM A(4)
80 DIM B(2)
90 A(1)=3D-.01454
100 A(2)=3D-.10453
110 A(3)=3D-.20791
120 A(4)=3D.00233
130 CE=3D.91775
140 SE=3D.39715
150 INPUT "LONGITUDE IN DEG."; LO
160 LI=3DABS(LO)
170 INPUT "LATITUDE IN DEG."; F
180 F=3DF*DR
190 S1=3DSIN(F)
200 CI=3DCOS(F)
210 INPUT "YEAR (4 DIGITS)"; IY
220 INPUT "MONTH (NUMERAL)"; IM
230 INPUT "DAY (NUMERAL)"; ID
240 C=3D360.
250 J=3D367*IY-INT(7*(IY+INT((IM+9)/12))/4)+INT(275*IM/9)+ID-730531.
260 INPUT "UNIVERSAL TIME =3D 0, ZONE TIME =3D 1, LOCAL MEAN TIME =3D 2"; Z
270 DT=3D0.
280 IF Z=3D0. THEN LET DT=3D-LO/C
290 IF Z=3D1. THEN LET DT=3D-(LI-15*INT((LI+7.5)/15))/C*SGN(LO)
300 INPUT "HOUR (4 DIGIT NUMERAL ON 24 HOUR CLOCK)"; H
310 ZO#=3DJ-.5
320 IF H>0 THEN GOTO 870
330 PRINT "DATA FOR ";IY; ", MONTH ";IM; ", DAY";ID
340 FOR L=3D1 TO 4
350 ON L GOTO 370, 650, 650, 360
360 C=3D347.81
370 M=3D.5+DT
380 K=3D1
390 M=3DM-DT
400 E=3DM-LO/360.
410 GOSUB 430
420 GOTO 530
430 D#-ZO#+E
440 IF ABS(E)>=3D1 THEN LET E=3DE-SGN(E)
450 GOSUB 1220
460 IF L=3D4 THEN GOSUB 1720
470 T=3DT+LO+360.*E
480 T=3DT-INT(T/360.)*360.
490 U=3DT-AS
500 IF ABS(U) > 180! THEN LET U=3DU-360.*SGN(U)
510 U=3DU/C
520 RETURN
530 M=3DM-U+DT
540 IF L<4 THEN LET K=3DK+1
550 ON K GOTO 600,560,600,580,600,620
560 IF M>=3DO. AND M<1. THEN GOTO 620
570 GOTO 590
580 IF M>=3DO. THEN GOTO 620
590 M=3DM-SGN(M)
600 K=3DK+1
610 GOTO 390
620 H=3DFNARCSIN(COS(F-DS))*RD
630 IF L=3D4 THEN LET H=3DH-.95*COS(H)
640 GOSUB 2160
650 GOSUB 2000
660 B(1)=3DM-H
670 B(2)=3DM+H
680 FOR I=3D1 TO 2
690 K=3D2*I-3
700 FOR N=3D1 TO 6
710 B(I)=3DB(I)-DT
720 E=3DB(I)-LO/360.
730 GOSUB 430
740 GOSUB 2000
750 B(I)=3DB(I)+K*H-U+DT
760 IF L<4 THEN LET N=3DN+1
770 ON N GOTO 820,780,820,800,820,830
780 IF B(I)>=3DO. AND B(I)<1. THEN GOTO 830
790 GOTO 810
800 IF B(I)>=3DO. THEN GOTO 830
810 B(I)=3DB(I)-SGN(B(I))
820 NEXT N
830 NEXT I
840 ON L GOSUB 1350,1400,1400,1610
850 NEXT L
860 GOTO 150
870 INPUT"SKY CONDITION =3D 1,2,3,10,";SK
880 PRINT"DATA FOR ";IY;", MONTH ";IM;", DAY ";ID;", AT ";H;" HOURS"
890 E=3DFNDEG(H/100.)/24.-DT-LO/360.
900 D#=3DZO#+E
910 N=3D1
920 GOSUB 1220
930 T=3DT+360.*E+LO
940 IF N=3D2 THEN GOSUB 1720
950 H=3DT-AS
960 GOSUB 2060
970 Z=3DH*DR
980 H=3DH-.95*(N-1)*COS(H*DR)
990 GOSUB 2160
1000 GOSUB 2200
1010 HA=3DINT(ABS(HA)+.5)*SGN(HA)
1020 ON N GOTO 1030, 1090
1030 IS=3D133775.*M/SK
1040 PRINT"SUN AZIMUTH (DEG.) ";AZ
1050 PRINT"SUN ALTITUDE (DOG.) ";HA
1060 PRINT"SUN ILLUMINANCE (LUX) ";IS
1070 N=3D2
1080 GOTO 940
1090 E=3DFNARCOS(COS(V-LS)*CB)
1100 P=3D.892*EXP(-3.343/((TAN(E/2.))^.632))+.0344*(SIN(E)-E*COS(E))
1110 P=3D.418*P/(1.-.005*COS(E)-.03*SIN(Z))
1120 IL=3DP*M/SK
1130 IS=3DIS+IL+.0005/SK
1140 PRINT"MOON AZIMUTH (DEG.) ";AZ
1150 PRINT"MOON ALTITUDE (DEG.) ";HA
1160 PRINT"MOON ILLUMINANCE (LUX) ";IL
1170 IL=3DINT(50.*(1.-COS(E=BB+.5)
1180 PRINT" (";IL;"% OF MOON ILLUMINATED)"
1190 PRINT"TOTAL ILLUMINANCE (LUX) ";IS
1200 GOTO 300
1210 END
1220 TD#=3D280.46#+.98565#*D#
1230 T=3DTD#-INT(TD#/360#)*360#
1240 IF T<O. THEN LET T=3DT+360.
1250 TD#=3D357.5#+.9856#*D#
1260 G=3D(TD#-INT(TD#/360#)*360#)*DR
1270 LS=3D(T+1.91*SIN(G))*DR
1280 AS=3DATN(CE*TAN(LS))*RD
1290 Y=3DCOS(LS)
1300 IF Y<O. THEN LET AS=3DAS+180.
1310 SD=3DSE*SIN(LS)
1320 DS=3DFNARCSIN(SD)
1330 T=3DT-180.
1340 RETURN
1350 R=3DM
1360 GOSUB 1700
1370 PRINT"SUN MERIDIAN PASSAGE AT ";R
1380 HA=3DINT(ABS(HA)+.5)*SGN(HA)
1390 PRINT"ALTITUDE AT MER. PASS. ";HA
1400 FOR 1=3D1 TO 2
1410 R=3DB(I)
1420 GOSUB 1700
1430 IF R>=3D4800. OR R<O. THEN GOTO 1680
1440 ON 2*(L-1)+I GOTO 1450,1470,1530,1550,1570,1590,1650,1670
1450 PRINT"TIME OF SUNRISE ";R
1460 GOTO 1680
1470 PRINT"TIME OF SUNSET ";R
1480 R=3DB(2)-B(1)
1490 IF R<O. THEN LET R=3DR+1.
1500 GOSUB 1700
1510 PRINT"TOTAL DAYLIGHT ";R
1520 GOTO 1680
1530 PRINT"BEGIN CIVIL TWILIGHT AT ";R
1540 GOTO 1680
1550 PRINT"END CIVIL TWILIGHT AT ";R
1560 GOTO 1680
1570 PRINT"BEGIN NAUTICAL TWILIGHT ";R
1580 GOTO 1680
1590 PRINT"END NAUTICAL TWILIGHT ";R
1600 GOTO 1680
1610 R=3DM
1620 GOSUB 1700
1630 PRINT"MOON MERIDIAN PASSAGE AT";R
1640 GOTO 1380
1650 PRINT"TIME OF MOONRISE        ";R
1660 GOTO 1680
1670 PRINT"TIME OF MOONSET         ";R
1680 NEXT I
1690 RETURN
1700 R=3DINT(100.*FNDMS(R*24.)+.5)
1710 RETURN
1720 TD#=3D218.32#+13.1764#*D#
1730 V=3DTD#-INT(TD#/360#)*360#
1740 IF V<O. THEN LET V=3DV+360.
1750 TD#=3D134.96#+13.06499#*D#
1760 Y=3D(TD#-INT(TD#/360#)*360#)*DR
1770 TD#=3D93.27#+13.22935#*D#
1780 O=3D(TD#-INT(TD#/360#)*360#)*DR
1790 TD#=3D235.7#+24.3815#*D#
1800 W=3D(TD#-INT(TD#/360#)*360#)*DR
1810 SB=3DSIN(Y)
1820 CB=3DCOS(Y)
1830 X=3DSIN(O)
1840 S=3DCOS(O)
1850 SD=3DSIN(W)
1860 CD=3DCOS(W)
1870 V=3DV+(6.29-1.27*CD+.43*CB)*SB+(.66+1.27*CB)*SD-.19*SIN(G)-.23*X*S
1880 V=3DV*DR
1890 Y=3D((5.13-.17*CD)*X+(.56*SB+.17*SD)*S)*DR
1900 SV=3DSIN(V)
1910 SB=3DSIN(Y)
1920 CB=3DCOS(Y)
1930 Q=3DCB*COS(V)
1940 P=3DCE*SV*CB-SE*SB
1950 SD=3DSE*SV*CB+CE*SB
1960 AS=3DATN(P/Q)*RD
1970 IF Q<O. THEN LET AS=3DAS+180.
1980 DS=3DFNARCSIN(SD)
1990 RETURN
2000 H=3D(A(L)-SI*SD)/(CI*COS(D))S
2010 IF ABS(H>1. THEN GOTO 2040
2020 H=3DFNARCOS(H)*RD/C
2030 RETURN
2040 H=3D1.5
2050 RETURN
2060 CD=3DCOS(PS)
2070 CS=3DCOS(H*DR)
2080 Q=3DSD*CI-CD*SI*CS
2090 P=3D-CD*SIN(H*DR)
2100 AZ=3DATN(P/Q)*RD
2110 IF Q<O. THEN LET AZ=3DAZ+180.
2120 IF AZ<O. THEN LET AZ=3DAZ+360.
2130 AZ=3DINT(AZ+.5)
2140 H=3DFNARCSIN(SO*SI+CD*CI*CS)*RD
2150 RETURN
2160 HA=3DH
2170 IF H<(-5./6.) THEN GOTO 2190
2180 HA=3DH+1./(TAN((H+8.59/(H+4.42))*DR))/60.
2190 RETURN
2200 U=3DSIN(HA*DR)
2210 X=3D753.6616
2220 S=3DFNARCSIN(X*COS(HA*DR)/(X+1.))
2230 M=3DX*(COS(S)-U)+COS(S)
2240 M=3DEXP(-.21*M)*U+.0289*EXP(-.042*M)*(1.+(HA+90.)*U/57.29578)
2250 RETURN

Thanks,
Chris Maness



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?CANnsUMG-2yaGgY-_aXtt2UTTRPCGFgFzhE0_sF74++saw5Uy1g>