0MODE7
1a=1
10CLS
12REMTRAN3 (C)NOV 1990 BY KEITH JOHNS
ON
20L$=""
22F$=""
30DIM N(20)
40DIM proc$(20)
44R$="KJ"
50tw=0
60def=1
62two$=""
66c$=" "
67d$="0"
68h=0
70num=0:nextline=20:M$="" :condition=
0:p=0
80REM translation prog part 2 TRAN2
88PRINT'"TRANSLATION BBC TO GW BASIC
BY K JOHNSON"
90PRINT''"THIS PROGRAM TRAN2 PULLS I
N A NAMED *SPOOL FILE READS ITS LINE
NUMBERS AND WRITES TO A SECOND NAM
ED FILE"
100PRINT"BEFORE IT WRITES TO THE SECON
D FILE IT ALTERS COMMANDS IN BBC BA
SIC TO COMMANDS IN IBM GW BASIC AN
D FORMS A SPOOL FILE OF THE TRANSLATE
D PROGRAM NOTE FIRST USE DEFT1 ON T
HE BBC PROGRAM BEFORE USING "
110PRINT" THIS PROGRAM"
120PRINT"PROCEDURE-LOAD-RENUMBER-NOTE
LAST LINE NUMBER-*SPOOL-LIST- *
SPOOL -RUN THIS PROGRAM- *EXEC-SECOND PR
OG-LIST SAVE"
130REM DATA TO COMPUTER
140INPUT'"ENTER NAME OF FILE TO BE ALT
ERED "file1$
150INPUT'"ENTER last line number "last
num
160INPUT'"ENTER NAME OF FINAL TRANSLAT
ION " file2$
170run=1
180CLS
190IF run=2 THEN tw=0:def=1:num=0:next
line=10:M$=""
200IF run=1 THEN Y=OPENIN(file1$)
210IF run=1 THEN X=OPENOUT(file2$)
220PRINT'''"LAST LINE NUMBER IS ";last
num
230IF run=1 THEN PRINTTAB(0,11)"OUTPUT
TO FILE "file2$
240REPEAT
250CHST=0
260D=BGET#Y
270L$=L$+CHR$(D)
280A$=L$
290B$=CHR$(10)
300m=LEN(B$)
310FOR K=1 TO LEN(L$):A=K
320IF MID$(A$,A,m)=B$ THEN GOTO 340
330GOTO 370
340IF MID$(A$,A-5,4)="GOTO" THEN GOTO
370
350IF MID$(A$,A-4,4)="GOTO" THEN GOTO
370
360line$=LEFT$(L$,A-1):L$=MID$(L$,A+1)
:CHST=1:nextline=nextline+10
370NEXT
380IF CHST=1 THEN A$=line$ :GOSUB 450
382IF LEN(L$)=240 THEN L$=""
390UNTIL EOF#(Y)
400A$=L$:line$=L$:GOSUB 450
410CLOSE#X
420CLOSE#Y
430IF run=2 THEN GOTO 180
440END
450REM JUMPS HERE ON GOSUB
460tline$=A$
470PROCmode
480PROCmove
490REM REPEAT UNTILS DONE ON FIRST RUN
500PROCdraw
510PROCdraw
520PROCdraw
530PROCinkey
540PROCtab
544PROCslash
550PROCinput
590PROCchain
600PROCgets
610PROCdeg
620PROCdeg
630PROCdeg
640PROCdeg
650PROCdeg
660PROCdeg
670PROCdeg
680PROCdeg
690PROCdeg
700PROCdeg
710PROCrad
720PROCrad
730PROCrad
740PROCrad
750PROCrad
760PROCrad
770PROCrad
780PROCrad
790PROCrad
800PROCrad
810PROCrad
820PROCrad
830PROCdr
833PROCplot
835PROCslash
840PROCwrite
850tw=0:REM on run 1 defprocs endprocs
sorted and line nums remembered
860RETURN
862END
870m=LEN(STR$(nextline))
880tw=0:REM comes here on run 2 to sor
t out procs into gosubs
890A$=line$
900PROCproc
910IF CHST=1 THEN GOTO 930
920GOTO940
930PROCwritetline
940IF tw=1 THEN GOTO 960
950PROCwrite
970PRINTTAB(0,12)" inputting line numb
er ";nextline
980PRINTTAB(0,15)" outputting line num
ber ";nextline ;TAB(33,15)"----"
990CHST=0
1000DEFPROCparse
1010CHST=0
1020FOR K=1 TO LEN(A$):A=K
1030IF MID$(A$,A,num)=B$ THEN M$=LEFT$(
A$,A-1):R$=MID$(A$,A+num):CHST=1:tw=1:K=
LEN(A$)
1040NEXT
1050ENDPROC
1060REM
1070REM=****** MOVE
1080REM
1090DEFPROCmove
1100B$="MOVE"
1110num=LEN(B$)
1120PROCparse
1130IF CHST=1 THEN GOTO 1140 ELSE GOTO
1250
1140CHST=0
1150B$=",":num=1
1160FOR K=1 TO LEN(R$):A=K
1170IF MID$(R$,A,num)=B$ THEN X%=VAL(LE
FT$(R$,A-num)):Y%=VAL(MID$(R$,A+num)):r=
LEN(STR$(Y%)):remain$=MID$(R$,A+1+num+r)
:CHST=1
1180NEXT
1190REM TRAN FOR SCREEN 2
1200 LET x%=X%/2
1210 LET y%=(1024-Y%)/5.12
1220insert$="LINE("+STR$(x%)+","+STR$(y
%)+")-("+STR$(x%)+","+STR$(y%)+")"
1230tline$=M$+insert$+remain$
1240A$=tline$
1250ENDPROC
1260REM
1270REM*** DRAW
1280REM
1290DEFPROCdraw
1300B$="DRAW":num=LEN(B$)
1310PROCparse
1320 IF CHST=1 THEN GOTO 1330 ELSE GOT
O 1432
1330CHST=0
1340B$=",":num=1
1350FOR K=1 TO LEN(R$):A=K
1360IF MID$(R$,A,num)=B$ THEN X%=VAL(LE
FT$(R$,A-num)):Y%=VAL(MID$(R$,A+num)):r=
LEN(STR$(Y%)):remain$=MID$(R$,A+1+num+r)
:a=A:CHST=1
1370NEXT
1380REM TRAN FOR SCREEN 2
1390LET x%=X%/2
1400LET y%=(1024-Y%)/5.12
1410insert$="LINE-("+STR$(x%)+","+STR$(
y%)+")"
1412IF X%=0 AND Y%=0 THEN insert$="LINE
-("+LEFT$(R$,a-num)+","+MID$(R$,a+num):G
OTO 1423
1420tline$=M$+insert$+remain$
1422GOTO1430
1423tline$=M$+insert$
1430A$=tline$
1432ENDPROC
1433REM
1434REM*** PLOT
1435REM
1436DEFPROCplot
1440B$="PLOT":num=LEN(B$)
1450PROCparse
1460 IF CHST=1 THEN GOTO 1470 ELSE GOT
O 1562
1470A$=M$+R$
1471B$="85,":num=LEN(B$)
1472PROCparse
1473A$=M$+R$
1475CHST=0
1480B$=",":num=1
1490FOR K=1 TO LEN(R$):A=K
1500IF MID$(R$,A,num)=B$ THEN X%=VAL(LE
FT$(R$,A-num)):Y%=VAL(MID$(R$,A+num)):r=
LEN(STR$(Y%)):remain$=MID$(R$,A+num+r):C
HST=1
1510NEXT
1520REM TRAN FOR SCREEN 2
1530LET x%=X%/2
1540LET y%=(1024-Y%)/5.12
1550insert$="LINE-("+STR$(x%)+","+STR$(
y%)+")"
1560tline$=M$+insert$
1561A$=tline$
1562ENDPROC
1570REM** MODE
1580REM
1600DEFPROCmode
1610B$="MODE"
1620num=LEN(B$)
1630PROCparse
1640 IF CHST=1 THEN tline$=M$+"SCREEN 2
:CLS":A$=tline$
1650ENDPROC
1660DEFPROCdeg
1670B$="DEG"
1680num=LEN(B$)
1690PROCparse
1700IF CHST=1 THEN tline$=M$+"180/PI*"+
R$
1710A$=tline$
1720ENDPROC
1730DEFPROCrad
1740B$="RAD"
1750num=LEN(B$)
1760PROCparse
1770IF CHST=1 THEN tline$=M$+"PI/180*"+
R$
1780A$=tline$
1790ENDPROC
1800DEFPROCproc
1810B$="PROC"
1820num=LEN(B$)
1830PROCparse
1840IF CHST=1 THEN GOTO 1850 ELSE GOTO
1910
1850FOR K=1 TO 20
1860d%=LEN(proc$(K))-LEN(R$)
1870IF d%<0 THEN R$=LEFT$(R$,LEN(R$)+d%
)
1880IF d%>=0 THEN proc$(K)=LEFT$(proc$(
K),LEN(proc$(K))-d%)
1890IF proc$(K)=R$ THEN tline$=M$+"GOSU
B"+STR$(N(K)) :K=21
1900NEXT
1910ENDPROC
1920DEFPROCwrite
1930A$=tline$
1940PRINTTAB(0,18)"
"
1944*FX15,0
1950PRINTTAB(0,18)A$
1960BPUT#X ,&0D
1970FOR K=1 TO LEN(A$):A=K
1980BPUT#X ,ASC(MID$(A$,A,1))
1990NEXT
2000ENDPROC
2010DEFPROCwritetline
2020tw=1
2030A$=tline$
2040PRINTTAB(0,18)"
"
2050PRINTTAB(0,18)tline$
2060BPUT#X ,&0D
2070FOR K=1 TO LEN(A$):A=K
2080BPUT#X ,ASC(MID$(A$,A,1))
2090NEXT
2100ENDPROC
2110DEFPROCrepeat
2120B$="REPEAT"
2130num=LEN(B$)
2140PROCparse
2150IF CHST=1 THEN rline$=M$ :tline$=M$
+"REM REPEAT"
2160ENDPROC
2170REM
2180REM*** *DR.2
2190REM
2200DEFPROCdr
2210B$="*DR.2"
2220num=LEN(B$)
2230CHST=0
2240num=LEN(B$)
2250PROCparse
2260IF CHST=1 THEN tline$=CHR$(10)
2270ENDPROC
2280DEFPROCnrt
2290IF CHST=1 THEN B$=CHR$(10):num=LEN(
B$)
2300PROCparse
2310IF CHST=1 THEN A$=M$
2320ENDPROC
2330DEFPROCgets
2340B$="GET$"
2350num=LEN(B$)
2360A$=tline$
2370PROCparse
2380IF CHST=1 THEN M$=(LEFT$(M$,LEN(M$)
-3)):tline$=M$+"INPUT A$"+R$
2390ENDPROC
2400REM
2410REM INKEY
2420REM
2430DEFPROCinkey
2440 B$="INKEY"
2450num=LEN(B$)
2460A$=tline$
2470PROCparse
2480IF CHST=1 THEN m$=M$ :r$=R$ :GOTO 2
500
2490GOTO 2630
2500 B$="("
2510num=LEN(B$)
2520A$=r$
2530PROCparse
2540IF CHST=1 THEN t$=R$:GOTO 2560
2550GOTO 2630
2560A$=R$
2570 B$=")":num=1
2580PROCparse
2590IF CHST=1 THEN V=VAL(M$) :e$=R$:GOT
O 2600 ELSE GOTO 2620
2600PROCchange
2610tline$=m$+" ASC(A$)="+STR$(asc)+e$
2620A$=tline$
2630ENDPROC
2640DEFPROCchange
2650IF V=-49 THEN asc=49
2660IF V=-50 THEN asc=50
2670IF V=-18 THEN asc=51
2680IF V=-19 THEN asc=52
2690IF V=-20 THEN asc=53
2700IF V=-53 THEN asc=54
2710IF V=-37 THEN asc=55
2720IF V=-22 THEN asc=56
2730IF V=-39 THEN asc=57
2740IF V=-66 THEN asc=65
2750IF V=-101 THEN asc=66
2760IF V=-83 THEN asc=67
2770IF V=-51 THEN asc=68
2780IF V=-35 THEN asc=69
2790IF V=-68 THEN asc=70
2800IF V=-84 THEN asc=71
2810IF V=-85 THEN asc=72
2820IF V=-38 THEN asc=73
2830IF V=-70 THEN asc=74
2840IF V=-71 THEN asc=75
2850IF V=-87 THEN asc=76
2860IF V=-102 THEN asc=77
2870IF V=-86 THEN asc=78
2880IF V=-56 THEN asc=80
2890IF V=-17 THEN asc=81
2900IF V=-99 THEN asc=32
2901IF V=-100 THEN asc=86
2902IF V=-54 THEN asc=85
2903IF V=-55 THEN asc=79
2904IF V=-52 THEN asc=82
2906IF V=-82 THEN asc=83
2907IF V=-36 THEN asc=84
2908IF V=-34 THEN asc=87
2909IF V=-67 THEN asc=88
2910IF V=-69 THEN asc=89
2911IF V=-98 THEN asc=90
2912IF V=-40 THEN asc=48
2913ENDPROC
2920REM
2930REM***** CHAIN
2940REM
2950DEFPROCchain
2960ch=0
2970ch=ch+1
2980IF ch=1 THEN B$="CHAIN" ELSE B$="CH
."
2990num=LEN(B$)
3000A$=tline$
3010PROCparse
3020 IF CHST=1 THEN m$=M$+"LOAD"+CHR$(3
4):r$=R$:GOTO 3040
3030GOTO 3110
3040A$=r$
3050B$=CHR$(34):num=1
3060PROCparse
3061IF CHST=1 THEN A$=M$+R$
3062B$=CHR$(34):num=1
3064PROCparse
3070IF CHST=1 THEN prog$=M$
3080IF CHST=1 THEN tline$=m$+prog$+CHR$
(34)+",R"+R$
3090IF ch=1 THEN GOTO 2970
3100A$=tline$
3110ENDPROC
3111REM
3112REM** TAB
3113REM
3120DEFPROCtab
3122m$="":r$=""
3130B$="TAB("
3140num=LEN(B$)
3150PROCparse
3160IF CHST=1 THEN m$=M$:r$=R$:GOTO 318
0
3170GOTO 3380
3180A$=r$
3190yy=VAL(r$)
3200A$=r$
3202B$=","
3203num=LEN(B$)
3210PROCparse
3220IF CHST=1 THEN two$=R$
3230xx=VAL(two$)
3240B$=")"
3244A$=two$
3245num=LEN(B$)
3250PROCparse
3260IF CHST=1 THEN last$=R$ :i$=M$
3302A$=m$
3303B$="PRINT"
3304num=LEN(B$)
3305PROCparse
3306IF CHST=1 THEN m$=M$
3350PROCswop
3360IF STR$(xx)=i$ THEN one$=m$+"LOCATE
"+d$+","+STR$(yy)+":PRINT"
3362IF STR$(xx)<>i$ THEN one$=m$+"LOCAT
E "+i$+","+STR$(yy)+":PRINT"
3370tline$=one$+last$
3375A$=tline$
3380ENDPROC
3390DEFPROCswop
3400h%=xx
3410IF h%>=18 THEN h=18+(32-h%)*0.5
3412IF h%<18 THEN h=h%
3420d%=h
3430d$=STR$(d%)
3440ENDPROC
3444REM
3445REM* GETS
3446REM
3450DEFPROCget
3460B$="GET$"
3470num=LEN(B$)
3480PROCparse
3490IF CHST=1 THEN M$=LEFT$(M$,(LEN(M$)
-3)):tline$=M$+R$:A$=tline$
3500ENDPROC
3600REM
3610REM *** ' ***
3620REM
3630DEFPROCslash
3640B$="'"
3650num=1
3660PROCparse
3670 IF CHST=1 THEN A$=M$+R$
3680tline$=A$
3690ENDPROC
3700REM
3710REM INPUT
3720REM
3730DEFPROCinput
3740B$="INPUT"
3744CHST=0
3750num=LEN(B$)
3760PROCparse
3770IF CHST=0 THEN 3840
3771IF CHST=1 THEN F$=M$
3772IF MID$(R$,1,1)=CHR$(34) THEN A$=MI
D$(R$,2) ELSE GOTO 3840
3780B$=CHR$(34)
3790num=LEN(B$)
3800PROCparse
3810IF CHST=1 THEN in$=M$
3820tline$=F$+"INPUT"+CHR$(34)+in$+CHR$
(34)+";"+R$
3830A$=tline$
3840ENDPROC