100 CLS
110 A$=STRING$(80,205)
120 PRINT A$
130 PRINT TAB(30)"DISTAR  7005-A.BAS "
140 COLOR 23,0,0
150 PRINT :PRINT :PRINT TAB(38)"IPCO"
160 COLOR 7,0,0
170 PRINT :PRINT :PRINT TAB(29)"INTERNATIONAL PC OWNERS"
180 PRINT :PRINT :PRINT TAB(17)"p.o. box 10426, pittsburgh, pennsylvania 15234"
190 PRINT A$
200 PRINT :PRINT :PRINT :PRINT :PRINT
210 PRINT TAB(28)"PRESS ANY KEY TO CONTINUE"
220 A$=INKEY$:IF A$="" THEN 220
230 CLS
240  KEY OFF  '    "DISTAR" of August 9, 1982, For Pittsburgh in 1982   JJS
250  C1=5:P=57.29578:LAT1=42.48/P:LONG1=80.22/P:IN=99.3324  '0Z Dec 30 81
260  CLS:PRINT TAB(24);CHR$(34);"DISTAR";CHR$(34);" computes:": LOCATE 3,5
270  PRINT "1. Great Circle Distance and the Initial Heading.": Y2=0
280  PRINT TAB(5);"2. Current Position of a star, given its celestial address."
290  PRINT: INPUT "     Enter your choice ", CHOICE
300  IF CHOICE <>1 AND CHOICE <>2 THEN 240 ELSE PRINT
310  PRINT "       Entries can be made either in decimal degrees or in "
320  PRINT "       Degrees, Minutes and Seconds, separated by colons."
330 PRINT: PRINT TAB(5);"Hit 'Enter' if the reference point is to be ";
340 PRINT "the Pittsburgh Airport" :PRINT
350 INPUT "     Otherwise enter Latitude of new reference point ",A$
360 IF A$="" THEN LOCATE 13: PRINT SPC(23);: GOTO 400
370 GOSUB 1010: LAT1=L/P: PRINT TAB(36);
380 INPUT "and its Longitude ",A$: GOSUB 1010: IF L<0 THEN L=L+360
390 LONG1=L/P:PRINT TAB(20)
400 IF CHOICE=2 THEN PRINT " Both date and time are necessary":PRINT:GOTO 510
410 PRINT TAB(24);:INPUT "Enter Latitude of destination ",A$:GOSUB 1010:LAT2=L/P
420 PRINT TAB(42);:INPUT "& longitude ",A$:GOSUB 1010:PRINT:IF L<0 THEN L=L+360
430 LONG2=L/P:IF ABS(LAT1)>1.58 OR ABS(LAT2)>1.58 THEN PRINT "Where?":GOTO 490
440 GOSUB 1080:SM=INT(NM*11.5+.5)/10:KM=INT(NM*18.5+.5)/10:N=INT(10*NM+.5)/10
450 IF NM>3 THEN 470 ELSE PRINT:PRINT "Distance is";CINT(100*NM)/100;"NM, or";
460 PRINT CINT(NM*6076.1);"feet and, the direction is";CINT(AZ): GOTO 490
470 LOCATE 19:PRINT "Great Circle Distance is ";N;"NM   ";SM;"SM   ";KM;"KM"
480 PRINT:PRINT "Initial Heading is ";:PRINT USING "###";AZ;:PRINT CHR$(248)
490 LOCATE 24:LINE INPUT "'A' for another, anything else for the Menu  ";Y$
500 IF Y$<>"A" AND Y$<>"a" THEN 250 ELSE CLS: LOCATE 13,1: GOTO 410
510 PRINT "The computer date is ";DATE$;:INPUT "    Correct or hit Enter ",D$
520 IF D$="" THEN 530 ELSE DATE$=D$+"-82"
530 PRINT "Computer time EST is ";TIME$;:INPUT "      Correct or hit Enter ",T$
540 Z2$="###.#"+CHR$(248):Z1$="+##.#"+CHR$(248): IF T$<>"" THEN TIME$=T$
550 PRINT: INPUT "Enter Sidereal Hour Angle in Degrees ",A$:GOSUB 1010: SHA=L
560 INPUT "   Also, enter declination with sign ",A$:GOSUB 1010: DEC=L
570 '       DAYS ELAPSED SINCE START OF YEAR
580 X = VAL(LEFT$(DATE$,2)):            LAT2=DEC/P:IF ABS(LAT2)>1.565 THEN 490
590 IF X>1 THEN D= 31: IF X> 2 THEN D= 59:IF X> 3 THEN D= 90:IF X>4 THEN D=120
600 IF X>5 THEN D=151: IF X> 6 THEN D=181:IF X> 7 THEN D=212:IF X>8 THEN D=243
610 IF X>9 THEN D=273: IF X>10 THEN D=304:IF X>11 THEN D=334
620 D1=D + VAL(MID$(DATE$,4,2)):GOSUB 940:CLS:GOSUB 740: P$=DATE$
630 '            SCREEN PRINTING ROUTINE
640 IF P$<>DATE$ THEN 570
650 IF Y2<1 AND ABS(H)<.01 THEN H=-H:Y2=2:GOSUB 740
660 LOCATE 3,2:PRINT "EST time is ";TIME$;TAB(30);"LHA of Aries is ";
670 PRINT USING Z2$;R2;:PRINT TAB(59);"GHA of Aries is ";: PRINT USING Z2$;R1
680 LOCATE 7,10:PRINT "For a celestial object of SHA ";:PRINT USING Z2$;SHA;
690 PRINT " and Declination of ";:PRINT USING "+##.#";DEC: LOCATE 11,3
700 PRINT "Its Elevation is ";:PRINT USING Z1$;H;:PRINT " at an Azimuth of ";
710 PRINT USING Z2$;AZ;:PRINT " and Local Hour Angle of ";:PRINT USING Z2$;LHA
720 Z$=INKEY$:IF Z$="A" OR Z$="a" THEN CLS:LOCATE 10,10:GOTO 550
730 IF Z$>CHR$(31) THEN 250 ELSE GOSUB 940: GOTO 630
740 '            RISING AND SETTING
750 LOCATE 15,4:W1=ABS((LAT1-LAT2)*P):W2=ABS((LAT1+LAT2)*P)
760 IF W1>90 THEN PRINT "And it never rises at this latitude":   GOTO 920
770 IF W2>90 THEN PRINT "And it never sets at this latitude":    GOTO 920
780 X=SIN(LAT2)/COS(LAT1):GOSUB 1190:AZR=CINT(Z*P):AZS=360-AZR:K=15.04107
790 X=SIN(Z)/COS(LAT2):IF ABS(X)<.99999 THEN GOSUB 1210 ELSE Z=0
800 Z1=90/P-Z:E1=Z1*P:IF DEC>0 THEN E1=180-E1
810 IF H<0 THEN TR=T+(360-E1-LHA)/K:TS=TR-(360-2*E1)/K:  GOTO 840
820 IF LHA>180 THEN TR=T-(E1-360+LHA)/K ELSE TR=T-(E1+LHA)/K
830 TS=TR+2*E1/K:IF TS>24 THEN TS=TS-24
840 IF TR<0 THEN TR=TR+24
850 IF TR>24 THEN TR=TR-24
860 IF TS<0 THEN TS=TS+24
870 B=TR:GOSUB 930: HR$=B$: MR$=C$:B=TS:GOSUB 930: IF H>0 THEN 900
880 PRINT "   It set at ";B$;":";C$;"  Az of ";AZS;
890 PRINT " and will rise at ";HR$;":";MR$;"  Az of ";AZR:      GOTO 920
900 PRINT "   It rose at ";HR$;":";MR$;"  Az of ";AZR;
910 PRINT " and will set at ";B$;":";C$;"  Az of ";AZS:
920 LOCATE 24,14:PRINT DATE$;"   'A' for another, otherwise the Menu";:RETURN
930 B$=STR$(INT(B)):C=(B-INT(B))*60+100.1:C$=MID$(STR$(C),3,2):RETURN
940 '              COMPUTE ARIES
950 A$=TIME$:GOSUB 1010:T=L:IF T>T3 AND Q1<1 THEN Q1=2:GOTO 570
960 R1=IN+D1*.985646+(T+C1)*15.041:R1=(R1/360-INT(R1/360))*360   'GHA of Aries
970 R2=R1-LONG1*P: IF R2<0 THEN R2=R2+360                        'LHA of Aries
980 LHA=R2+SHA: IF LHA>360 THEN LHA=LHA-360                       'LHA of star
990 LONG2 =LHA/P+LONG1:IF LONG2>360/P THEN LONG2=LONG2-360/P
1000 GOSUB 1080: H=(90-(NM/60)): RETURN
1010 '         TO ACCEPT EITHER DECIMALS OR D,M,S
1020 L$="":L1=0:L2=0:L3=0:GOSUB 1040:IF VAL(A$)>=0 THEN L=L1+L2+L3: RETURN
1030 L=L1-L2-L3: RETURN
1040 FOR N=1 TO LEN (A$): IF ASC(MID$(A$,N,1))=58 THEN 1060
1050 L$=L$+MID$(A$,N,1): L1=VAL(L$): NEXT:RETURN
1060 L2=VAL(MID$(A$,N+1,2))/60: IF LEN(A$)<>N+5 THEN RETURN
1070 L3=VAL(MID$(A$,N+4,2))/3600:RETURN
1080 '             COMPUTE NM AND Az
1090 DIF=LONG2-LONG1:X=SIN(LAT1)*SIN(LAT2)+COS(LAT1)*COS(DIF)*COS(LAT2)
1100 AZ=0: IF ABS(X)<.9995 THEN GOSUB 1210:NM=Z*P*60: GOTO 1130
1110 NM=P*60*SQR((LAT1-LAT2)^2+((DIF)*COS(LAT1))^2):IF NM=0 THEN RETURN
1120 X=(LAT2-LAT1)*P*60/NM:IF ABS(X)<.999995 THEN GOSUB 1210:AZ=Z*P: GOTO 1170
1130 IF ABS(LAT2-LAT1)<.001 THEN AZ=90: GOTO 1170
1140 IF ABS(DIF)<.001 OR ABS(LAT1)>89.9/P THEN 1150 ELSE 1160
1150 IF LAT2>LAT1 THEN RETURN ELSE AZ=180:RETURN
1160 X=(SIN(LAT2)-SIN(LAT1)*COS(Z))/(COS(LAT1)*SIN(Z)):GOSUB 1210:AZ=Z*P
1170 IF SIN(DIF)=<0 THEN RETURN
1180 AZ=360-AZ: RETURN
1190 IF ABS(X)<.9999999 THEN 1210 ELSE IF LAT2>LAT1 THEN AZ=0:RETURN
1200 AZ=180: RETURN
1210 Z=(1.570796-ATN(X/SQR(1-X*X))): RETURN
BS(X)<.9999999 THEN 1210 ELSE IF LAT2>LAT1 THEN AZ=0:RETURN
1200 AZ=180: RETURN
1210