Home » CEEFAX disks » telesoftware5.adl » 07-02-88/LISTER2 » Compare
Compare 07-02-88/LISTER2 with 07-02-88/LISTER3
| File: | CEEFAX disks » telesoftware5.adl » 07-02-88/LISTER2 |
| Compared with: | CEEFAX disks » telesoftware5.adl » 07-02-88/LISTER3 |
| Similarity: | 51% of bytes duplicated |
265 of 428 lines (75.0%) are identical in the two listings. Duplicated Different
Line numbers are ignored when comparing lines, so that renumbered programs still match.
| 07-02-88/LISTER2 | 07-02-88/LISTER3 |
|---|---|
| 10REM BASIC PROGRAM LISTER | 10REM BASIC PROGRAM LISTER |
| 20REM This program will list any | 20REM This program will list any |
| 30REM BASIC program from disc/net to | 30REM BASIC program from disc/net to |
| 40REM screen or printer. It will | 40REM screen or printer. It will |
| 50REM properly indent program lines, | 50REM properly indent program lines, |
| 60REM split multiple statements, | 60REM split multiple statements, |
| 70REM split and indent IF statements | 70REM split and indent IF statements |
| 80REM and emphasise the DEFinitions | 80REM and emphasise the DEFinitions |
| 90REM of all procedures and | 90REM of all procedures and |
| 100REM functions. | 100REM functions. |
| 110 | 110 |
| 120REM (c) Derek Grainge | 120REM (c) Derek Grainge |
| 130REM 18th April , 1987 | 130REM 18th April , 1987 |
| 140REM Loretto School, Musselburgh | 140REM Loretto School, Musselburgh |
| 150 | 150 |
| 160 | 160 |
| 170REM set up section | 170REM set up section |
| 180ON ERROR GOTO 1920 | 171REM Lines 190,200,240,300 |
| 172REM are NET/ADFS - specific. | |
| 173REM Get rid of them if using disc. | |
| 174REM Line 200 refers to a program | |
| 175REM called PUTGET available | |
| 176REM through MUSE or SJ research. | |
| 180ON ERROR GOTO 1910 | |
| 190*NET | 190*NET |
| 200*PUTGET2 | 200*PUTGET2 |
| 210MODE7 | 210MODE7 |
| 220PRINT"SETTING UP. PLEASE WAIT ..." | 220PRINT"SETTING UP. PLEASE WAIT ..." |
| 230DIM A% 40 ,NAME$(127),linebuffer 256 | 230DIM A% 40 ,NAME$(127),linebuffer 256 |
| 240*DIR $ | 240*DIR $ |
| 241REM The file called "FILE" | |
| 242REM contains a list of all the | |
| 243REM BASIC keywords. This avoids | |
| 244REM problems with differences | |
| 245REM between BASIC versions 1,2 etc | |
| 246REM However, In BASIC1 you will | |
| 247REM find that OPENIN appears as | |
| 248REM OPENUP. If this is a problem | |
| 249REM remove the REM on line 301. | |
| 250X=OPENUP("FILE") | 250X=OPENUP("FILE") |
| 260FOR I=0 TO 127 | 260FOR I=0 TO 127 |
| 270INPUT#X,NAME$(I) | 270INPUT#X,NAME$(I) |
| 280NEXT | 280NEXT |
| 290CLOSE#X | 290CLOSE#X |
| 300*NET | 300*NET |
| 301REM IF ?&8015=49 THEN NAME$(45)="OPENIN" | |
| 310indent=0:margin=6:fornext=0:repuntil=0:space=32:return=13:remark=&F4:quote=34:comma=44:for=&E3:repeat=&F5:until=&FD:next=&ED:lineno=141:define=221:printable=127:colon=58:then=&8C:else=&8B | 310indent=0:margin=6:fornext=0:repuntil=0:space=32:return=13:remark=&F4:quote=34:comma=44:for=&E3:repeat=&F5:until=&FD:next=&ED:lineno=141:define=221:printable=127:colon=58:then=&8C:else=&8B |
| 320if=&E7:test1$=CHR$(quote)+CHR$(remark)+CHR$(for)+CHR$(else)+CHR$(repeat)+CHR$(next)+CHR$(until) | 320if=&E7:test1$=CHR$(quote)+CHR$(remark)+CHR$(for)+CHR$(else)+CHR$(repeat)+CHR$(next)+CHR$(until) |
| 330test2$=CHR$(then)+CHR$(if)+CHR$(else)+CHR$(colon) | 330test2$=CHR$(then)+CHR$(if)+CHR$(else)+CHR$(colon) |
| 340single=1:double=2 | 340single=1:double=2 |
| 350 | 350 |
| 360 | 360 |
| 370REM THE MAIN PROGRAM REPEATS ITSELF | 370REM THE MAIN PROGRAM REPEATS ITSELF |
| 380REPEAT | 380REPEAT |
| 390REM CHOOSE A DIRECTORY | 390REM CHOOSE A DIRECTORY |
| 391REM To select a different directory | |
| 392REM just type in its name. If you | |
| 393REM are happy with the current one, | |
| 394REM press return. | |
| 395REM If you are using the DFS there's | |
| 396REM is no point in doing all this, | |
| 397REM so delete lines 400 to 450. | |
| 400*DIR | 400*DIR |
| 410REPEAT | 410REPEAT |
| 420*CAT | 420*CAT |
| 430INPUT"WHICH DIRECTORY",A$ | 430INPUT"WHICH DIRECTORY",A$ |
| 440IF A$<>"" THEN PROCoscli("DIR "+A$) | 440IF A$<>"" THEN PROCoscli("DIR "+A$) |
| 450UNTIL A$="" | 450UNTIL A$="" |
| 460REM CHOOSE A PROGRAM | 460REM CHOOSE A PROGRAM |
| 470CLS:*CAT | 470CLS:*CAT |
| 480INPUT"NAME OF PROGRAM",P$:P%=linebuffer | 480INPUT"NAME OF PROGRAM",P$:P%=linebuffer |
| 490INPUT"STARTING AT LINE NO",startno | |
| 500REM CHOOSE OUTPUT PARAMETERS | 490REM CHOOSE OUTPUT PARAMETERS |
| 491REM 1. You can start from any line | |
| 492REM in the program by typing a | |
| 493REM line number. | |
| 494REM 2. I have arbitrarily limited | |
| 495REM the printing width to lie | |
| 496REM between 20 and 78. Change | |
| 497REM these if you wish. | |
| 498REM 3. Any word starting with Y | |
| 499REM will switch the printer on. | |
| 500INPUT"STARTING AT LINE NO",startno | |
| 510INPUT''"WIDTH OF LISTING ON SCREEN OR PAPER",R% | 510INPUT''"WIDTH OF LISTING ON SCREEN OR PAPER",R% |
| 520IF R%<20 OR R%>78 THEN GOTO 510 | 520IF R%<20 OR R%>78 THEN GOTO 510 |
| 530INPUT ''"PRINTER ON (Y/N) ",Y1$ | 530INPUT ''"PRINTER ON (Y/N) ",Y1$ |
| 540IF LEFT$(Y1$,1)="Y" THEN INPUT"ECONET PRINTER (Y/N)",Y2$ ELSE Y2$="N" | 540IF LEFT$(Y1$,1)="Y" THEN INPUT"ECONET PRINTER (Y/N)",Y2$ ELSE Y2$="N" |
| 550*FX 5,1 | 550*FX 5,1 |
| 560IF LEFT$(Y2$,1)="Y" THEN *FX 5,4 | 560IF LEFT$(Y2$,1)="Y" THEN *FX 5,4 |
| 570PRINT''''' | 570PRINT''''' |
| 580IF LEFT$(Y1$,1)="Y" THEN VDU 2,1,27,1,40 | 580IF LEFT$(Y1$,1)="Y" THEN VDU 2,1,27,1,40 |
| 590IF R%<40 THEN MODE 7 ELSE MODE 3 | 581REM The VDU sequence 1,27,1,40 |
| 582REM selects NLQ printing on my | |
| 583REM CANON. Stick in your own | |
| 584REM code to select your | |
| 585REM preferred printing style. | |
| 590REM IF R%<40 THEN MODE 7 ELSE MODE 3 | |
| 591REM If you remove all the REM state- | |
| 592REM ments there will probably be | |
| 593REM enough room for the program | |
| 594REM to run in a mode with 80 | |
| 595REM characters to the line. In | |
| 596REM which case, remove the REM from | |
| 597REM line 590, but leave the IF | |
| 598REM statement behind! | |
| 600 | 600 |
| 610REM THE MAIN PROGRAM ITSELF | 610REM THE MAIN PROGRAM ITSELF |
| 611REM Open the file, and process each | |
| 612REM line until we reach the end. | |
| 620margin=6:fornext=0:repuntil=0 | 614margin=6:fornext=0:repuntil=0 |
| 630decode=TRUE:mode=single | 615decode=TRUE:mode=single |
| 640PRINT'P$' | 620PRINT'P$' |
| 650theend=FALSE | 630theend=FALSE |
| 660X=OPENUP(P$) | 640X=OPENUP(P$) |
| 670REPEAT | 650REPEAT |
| 680PROCloadline(linebuffer) | 660PROCloadline(linebuffer) |
| 690PROCcheck(linebuffer) | 670PROCcheck(linebuffer) |
| 700IF (NOT theend) AND highenough THEN PROClistline(linebuffer+4) | 680IF (NOT theend) AND highenough THEN PROClistline(linebuffer+4) |
| 710UNTIL theend | 690UNTIL theend |
| 720CLOSE#X | 700CLOSE#X |
| 730PRINT'' | 710PRINT'' |
| 740IF Y2$="N" THEN VDU 1,12 | 720IF Y2$="N" THEN VDU 1,12 |
| 750VDU 3 | 730VDU 3 |
| 760 | 740 |
| 770REM ANOTHER GO ? | 750REM ANOTHER GO ? |
| 751REM The program repeats until you | |
| 752REM reply with a word starting with | |
| 753REM N. | |
| 780INPUT''"ANOTHER GO",Y$ | 760INPUT''"ANOTHER GO",Y$ |
| 790UNTIL LEFT$(Y$,1)="N" | 770UNTIL LEFT$(Y$,1)="N" |
| 800END | 780END |
| 810REM END OF MAIN PROGRAM | 790REM END OF MAIN PROGRAM |
| 820 | 800 |
| 830 | 810 |
| 840REM CHECK A LINE FOR LEGALITY | 820REM CHECK A LINE FOR LEGALITY |
| 821REM The 1st char must be 13, and | |
| 822REM the 2nd less than 128. Check | |
| 823REM if within range for listing. | |
| 824REM Calculate the correct margin | |
| 825REM and print the line number. | |
| 850 | 830 |
| 860DEFPROCcheck(A%) | 840DEFPROCcheck(A%) |
| 870IF ?A%<>13 THEN theend=TRUE:VDU 3:PRINT"ILLEGAL BASIC STORAGE":ENDPROC | 850IF ?A%<>13 THEN theend=TRUE:VDU 3:PRINT"ILLEGAL BASIC STORAGE":ENDPROC |
| 880IF A%?1>127 THEN theend=TRUE:ENDPROC | 860IF A%?1>127 THEN theend=TRUE:ENDPROC |
| 890highenough=TRUE | 870highenough=TRUE |
| 900IF (A%?1)*256+A%?2<startno THEN highenough=FALSE:ENDPROC | 880IF (A%?1)*256+A%?2<startno THEN highenough=FALSE:ENDPROC |
| 910@%=5:margin=6+2*fornext+2*repuntil:IF margin<6 THEN margin=6 | 890@%=5:margin=6+2*fornext+2*repuntil:IF margin<6 THEN margin=6 |
| 920PRINT(A%?1)*256 + (A%?2) ;STRING$(margin-5," ");:@%=0:Q%=margin | 900PRINT(A%?1)*256 + (A%?2) ;STRING$(margin-5," ");:@%=0:Q%=margin |
| 930mode=single | 910mode=single |
| 940ENDPROC | 920ENDPROC |
| 950 | 930 |
| 960 | 940 |
| 970REM PRINT A PROGRAM LINE | 950REM PRINT A PROGRAM LINE |
| 951REM B% points the the line's text. | |
| 952REM Reset indent because IF state- | |
| 953REM ments are only indented while | |
| 954REM on the current line. | |
| 955REM calculate the line length. | |
| 956REM Calculate the margin and | |
| 957REM print each statement until | |
| 958REM finished. | |
| 980 | 960 |
| 990DEFPROClistline(B%) | 970DEFPROClistline(B%) |
| 1000indent=0 | 980indent=0 |
| 1010L%=?(B%-1)-4 | 990L%=?(B%-1)-4 |
| 1020K%=-1 | 1000K%=-1 |
| 1030margin=6+2*fornext+2*repuntil:IF margin<6 THEN margin=6 | 1010margin=6+2*fornext+2*repuntil:IF margin<6 THEN margin=6 |
| 1040Q%=margin | 1020Q%=margin |
| 1050REPEAT | 1030REPEAT |
| 1060PROCstatement | 1040PROCstatement |
| 1070UNTIL K%>=L%-1 | 1050UNTIL K%>=L%-1 |
| 1080PRINT | 1060PRINT |
| 1090ENDPROC | 1070ENDPROC |
| 1100 | 1080 |
| 1110 | 1090 |
| 1120REM PRINT ONE PROGRAM STATEMENT | 1100REM PRINT ONE PROGRAM STATEMENT |
| 1101REM Deal with each program state- | |
| 1102REM ment. BASIC doesn't have a | |
| 1103REM CASE statement , so ON .. GOTO | |
| 1104REM is the most efficient way of | |
| 1105REM selecting options. | |
| 1130 | 1110 |
| 1140DEF PROCstatement | 1120DEF PROCstatement |
| 1150PROCstripspaces | 1130PROCstripspaces |
| 1160REPEAT | 1150REPEAT |
| 1170PROCnextchar | 1160PROCnextchar |
| 1180a=INSTR(test1$,CHR$(char)) | 1170a=INSTR(test1$,CHR$(char)) |
| 1190ON a+1 GOTO 1270,1200,1210,1220,1230,1240,1250,1260 | 1180ON a+1 GOTO 1260,1190,1200,1210,1220,1230,1240,1250 |
| 1200PROCtext:GOTO 1340 | 1181REM line 1190 deals with a quote, |
| 1210PROCrem:GOTO 1340 | 1182REM 1200 with REM, 1210 with FOR |
| 1220fornext=fornext+1:PROCprint(space,decode):PROCprint(space,decode):GOTO 1270 | 1183REM 1220 with THEN, 1230 with |
| 1230indent=indent-2:PROCstartline:GOTO 1270 | 1184REM REPEAT, 1240 with NEXT, and |
| 1240repuntil=repuntil+1:PROCprint(space,decode):PROCprint(space,decode):GOTO 1270 | 1185REM 1150 with UNTIL. |
| 1250PROCcheck_commas:GOTO 1270 | 1190PROCtext:GOTO 1320 |
| 1200PROCrem:GOTO 1320 | |
| 1210fornext=fornext+1:PROCprint(space,decode):PROCprint(space,decode):GOTO 1260 | |
| 1220indent=indent-2:PROCstartline:GOTO 1260 | |
| 1230repuntil=repuntil+1:PROCprint(space,decode):PROCprint(space,decode):GOTO 1260 | |
| 1240PROCcheck_commas:GOTO 1260 | |
| 1260repuntil=repuntil-1:IF repuntil<0 THEN repuntil=0 | 1250repuntil=repuntil-1:IF repuntil<0 THEN repuntil=0 |
| 1270IF char=lineno THEN PROClineno(B%+K%+1) ELSE PROCprint(char,decode) | 1260IF char=lineno THEN PROClineno(B%+K%+1) ELSE PROCprint(char,decode) |
| 1280a=INSTR(test2$,CHR$(char)) | 1270a=INSTR(test2$,CHR$(char)) |
| 1290ON a+1 GOTO 1340,1330,1300,1310,1320 | 1280ON a+1 GOTO 1320,1310,1290,1300,1305 |
| 1300indent=indent+2:GOTO 1340 | 1281REM 1290 deals with IF, 1300 with |
| 1282REM ELSE, 1310 THEN, 1305 colon | |
| 1290indent=indent+2:GOTO 1320 | |
| 1310indent=indent+2 | 1300indent=indent+2 |
| 1320IF a=4 THEN PROCstripspaces:IF K%>=L%-1 THEN 1340 | 1305IF a=4 THEN PROCstripspaces:IF K%>=L%-1 THEN 1320 |
| 1330PROCstartline | 1310PROCstartline |
| 1340UNTIL K%>=L%-1 OR char=colon | 1320UNTIL K%>=L%-1 OR char=colon |
| 1350ENDPROC | 1330ENDPROC |
| 1360 | 1340 |
| 1370 | 1350 |
| 1380REM EXECUTE A * INSTRUCTION | 1360REM EXECUTE A * INSTRUCTION |
| 1361REM A% point to a small text | |
| 1362REM buffer where the * command | |
| 1363REM is placed. | |
| 1390 | 1370 |
| 1400DEFPROCoscli(A$) | 1380DEFPROCoscli(A$) |
| 1410$A%=A$ | 1390$A%=A$ |
| 1420X%=A% MOD 256 | 1400X%=A% MOD 256 |
| 1430Y%=A% DIV 256 | 1410Y%=A% DIV 256 |
| 1440CALL &FFF7 | 1420CALL &FFF7 |
| 1450ENDPROC | 1430ENDPROC |
| 1460 | 1440 |
| 1470 | 1450 |
| 1480REM DECODE A LINE NUMBER | 1460REM DECODE A LINE NUMBER |
| 1461REM Line numbers used by GOTO | |
| 1462REM GOSUB are stored in a | |
| 1463REM special format of a line | |
| 1464REM number flag followed by three | |
| 1465REM bytes. This is to avoid each | |
| 1466REM byte being >127 or <32 and | |
| 1467REM hence possibly being decoded | |
| 1468REM by BASIC as a control code or | |
| 1469REM a BASIC keyword! | |
| 1490 | 1470 |
| 1500DEFPROClineno(A%) | 1480DEFPROClineno(A%) |
| 1510LOCAL D1%,D2%,D3%,L | 1490LOCAL D1%,D2%,D3%,L |
| 1520D1%= ((A%?1)AND &3F) | 1500D1%= ((A%?1)AND &3F) |
| 1530D2%= ((A%?2)AND &3F) | 1510D2%= ((A%?2)AND &3F) |
| 1540D3%= (?A%) EOR &54 | 1520D3%= (?A%) EOR &54 |
| 1550L= D2%*256+D1%+(D3%AND 4)*256*16 +(D3% AND 48)*4 | 1530L= D2%*256+D1%+(D3%AND 4)*256*16 +(D3% AND 48)*4 |
| 1560IF Q%+LEN(STR$(L))*mode>R% THEN PROCstartline | 1540IF Q%+LEN(STR$(L))*mode>R% THEN PROCstartline |
| 1570PRINT L; | 1550PRINT L; |
| 1580K%=K%+3 | 1560K%=K%+3 |
| 1590Q%=Q%+LEN(STR$(L))*mode | 1570Q%=Q%+LEN(STR$(L))*mode |
| 1600ENDPROC | 1580ENDPROC |
| 1610 | 1590 |
| 1620 | 1600 |
| 1630REM CHECK A NEXT STATEMENT FOR COMMAS | 1610REM CHECK A NEXT STATEMENT FOR COMMAS |
| 1611REM A next statement may be | |
| 1612REM followed by one or more | |
| 1613REM variables, separated by commas. | |
| 1614REM By counting forwards through | |
| 1615REM the commas we know how many | |
| 1616REM NEXTs have beeen implied. | |
| 1617REM PS take care to avoid | |
| 1618REM 'outdenting' ! | |
| 1640 | 1620 |
| 1650DEF PROCcheck_commas | 1630DEF PROCcheck_commas |
| 1660fornext=fornext-1 | 1640fornext=fornext-1 |
| 1670pos=K% | 1650pos=K% |
| 1680REPEAT | 1660REPEAT |
| 1690pos=pos+1 | 1670pos=pos+1 |
| 1700IF B%?pos=comma THEN fornext=fornext-1 | 1680IF B%?pos=comma THEN fornext=fornext-1 |
| 1710UNTIL B%?pos=colon OR pos=L%-1 OR B%?pos=return | 1690UNTIL B%?pos=colon OR pos=L%-1 OR B%?pos=return |
| 1720IF fornext<0 THEN fornext=0 | 1700IF fornext<0 THEN fornext=0 |
| 1730ENDPROC | 1710ENDPROC |
| 1740 | 1720 |
| 1750 | 1730 |
| 1760REM INDENT THE MARGIN THE CORRECT # OF SPACES | 1740REM INDENT THE MARGIN THE CORRECT # OF SPACES |
| 1741REM Used to split multiple state- | |
| 1742REM ments or long lines. | |
| 1743REM FOR/NEXT REPEAT/UNTIL and | |
| 1744REM IF/THEN/ELSE statements | |
| 1745REM are all indented by two spaces. | |
| 1746REM The effects of indenting an | |
| 1747REM IF statement are only effective | |
| 1748REM for the current program line. | |
| 1770 | 1750 |
| 1780DEF PROCstartline | 1760DEF PROCstartline |
| 1790PRINT | 1770PRINT |
| 1800IF indent<0 THEN indent=0 | 1780IF indent<0 THEN indent=0 |
| 1810margin=6+2*fornext+2*repuntil+indent | 1790margin=6+2*fornext+2*repuntil+indent |
| 1820IF margin<6 THEN margin=6 | 1800IF margin<6 THEN margin=6 |
| 1830PRINT STRING$(margin," "); | 1810PRINT STRING$(margin," "); |
| 1840Q%=margin | 1820Q%=margin |
| 1850PROCstripspaces | 1830PROCstripspaces |
| 1860mode=single | 1850mode=single |
| 1870ENDPROC | 1860ENDPROC |
| 1880 | 1870 |
| 1890 | 1880 |
| 1900REM ERROR SECTION | 1890REM ERROR SECTION |
| 1891REM Escape will cause an exit to | |
| 1892REM this section, as will an error | |
| 1893REM in the program - which will be | |
| 1894REM reported. You are asked if | |
| 1895REM you wish another go. Because | |
| 1896REM an error might happen while | |
| 1897REM setting things up, the program | |
| 1898REM will have to be RUN again if | |
| 1899REM the error happened there. | |
| 1910 | 1900 |
| 1920CLOSE#0 | 1910CLOSE#0 |
| 1930VDU 12,3 | 1920VDU 12,3 |
| 1940IF ERR<>17 THEN REPORT:PRINT" at line ";ERL | 1930IF ERR<>17 THEN REPORT:PRINT" at line ";ERL |
| 1950INPUT''"ANOTHER GO ?",Y$ | 1940INPUT''"ANOTHER GO ?",Y$ |
| 1960IF LEFT$(Y$,1)="N" THEN END | 1950IF LEFT$(Y$,1)="N" THEN END |
| 1970IF ERL<370 THEN RUN | 1960IF ERL<370 THEN RUN |
| 1980GOTO 380 | 1970GOTO 380 |
| 1990 | 1980 |
| 2000 | 1990 |
| 2010REM GET A LINE FROM THE FILE | 2000REM GET A LINE FROM THE FILE |
| 2001REM The line format is char. 13 | |
| 2002REM followed by line no (hi byte) | |
| 2003REM If the hi byte is >127 that | |
| 2004REM marks the end of the program. | |
| 2005REM If all is well, the line no | |
| 2006REM (lo byte) and line length | |
| 2007REM follow, and then the code for | |
| 2008REM that line of program. | |
| 2020 | 2010 |
| 2030DEFPROCloadline(buf) | 2020DEFPROCloadline(buf) |
| 2040LOCAL a,b | 2030LOCAL a,b |
| 2050a=BGET#X | 2040a=BGET#X |
| 2060?buf=a | 2050?buf=a |
| 2070b=BGET#X | 2060b=BGET#X |
| 2080buf?1=b | 2070buf?1=b |
| 2090IF a<>13 THEN ENDPROC | 2080IF a<>13 THEN ENDPROC |
| 2100IF b>127 THEN ENDPROC | 2090IF b>127 THEN ENDPROC |
| 2110buf?2=BGET#X | 2100buf?2=BGET#X |
| 2120a=BGET#X | 2110a=BGET#X |
| 2130buf?3=a | 2120buf?3=a |
| 2140FOR b=4 TO a-1 | 2130FOR b=4 TO a-1 |
| 2150buf?b=BGET#X | 2140buf?b=BGET#X |
| 2160NEXT b | 2150NEXT b |
| 2170buf?a=13 | 2160buf?a=13 |
| 2180ENDPROC | 2170ENDPROC |
| 2190 | 2180 |
| 2200 | 2190 |
| 2210REM IGNORE ANY LEADING SPACES | 2200REM IGNORE ANY LEADING SPACES |
| 2220REM AT THE START OF A LINE | 2210REM AT THE START OF A LINE |
| 2211REM The program organises its own | |
| 2212REM indentation so it ignores yours | |
| 2230 | 2220 |
| 2240DEF PROCstripspaces | 2230DEF PROCstripspaces |
| 2250IF Q%>margin THEN ENDPROC | 2235IF Q%>margin THEN ENDPROC |
| 2260REPEAT | 2240REPEAT |
| 2270K%=K%+1 | 2250K%=K%+1 |
| 2280UNTIL K%>L%-1 OR B%?K%>space | 2260UNTIL K%>=L%-1 OR B%?K%>space |
| 2290K%=K%-1 | 2265K%=K%-1 |
| 2300ENDPROC | 2270ENDPROC |
| 2310 | 2280 |
| 2320 | 2290 |
| 2330REM GET THE NEXT CHARACTER | 2300REM GET THE NEXT CHARACTER |
| 2301REM Return a space if off the end | |
| 2302REM of the line, or if the char. | |
| 2303REM was a control code. Thus many | |
| 2304REM unlistable programs are now | |
| 2305REM listable! | |
| 2340 | 2310 |
| 2350DEF PROCnextchar | 2320DEF PROCnextchar |
| 2360K%=K%+1 | 2330K%=K%+1 |
| 2370IF K%>L%-1 THEN char=space ELSE char=B%?K% | 2340IF K%>L%-1 THEN char=space ELSE char=B%?K% |
| 2380IF char<space THEN char=space | 2350IF char<space THEN char=space |
| 2390ENDPROC | 2360ENDPROC |
| 2400 | 2370 |
| 2410 | 2380 |
| 2420REM DEAL WITH A REM STATEMENT | 2390REM DEAL WITH A REM STATEMENT |
| 2391REM The rest of the line will be | |
| 2392REM treated as text, but it may | |
| 2393REM include BASIC keywords, which | |
| 2394REM have to be decoded. | |
| 2430 | 2400 |
| 2440DEF PROCrem | 2410DEF PROCrem |
| 2450PROCprint(char,decode) | 2420PROCprint(char,decode) |
| 2460REPEAT | 2430REPEAT |
| 2470PROCnextchar | 2440PROCnextchar |
| 2480IF char=quote THEN PROCtext ELSE PROCprint(char,decode) | 2450IF char=quote THEN PROCtext ELSE PROCprint(char,decode) |
| 2490UNTIL K%>=L%-1 | 2460UNTIL K%>=L%-1 |
| 2500ENDPROC | 2470ENDPROC |
| 2510 | 2480 |
| 2520 | 2490 |
| 2530REM DEAL WITH TEXT BETWEEN QUOTES | 2500REM DEAL WITH TEXT BETWEEN QUOTES |
| 2501REM print the first quote, then | |
| 2502REM keep on printing until the | |
| 2503REM end of the string is found. | |
| 2504REM Guard against missing quotes | |
| 2505REM at the end of line! | |
| 2506REM Double quotes are no problem - | |
| 2507REM we toggle out and in to text | |
| 2508REM mode again. Codes >128 are | |
| 2509REM teletext control - ignore them. | |
| 2540 | 2510 |
| 2550DEF PROCtext | 2520DEF PROCtext |
| 2560PROCprint(char,NOT decode) | 2530PROCprint(char,NOT decode) |
| 2570REPEAT | 2540REPEAT |
| 2580PROCnextchar | 2550PROCnextchar |
| 2590PROCprint(char,NOT decode) | 2560PROCprint(char,NOT decode) |
| 2600UNTIL K%>=L%-1 OR char=quote | 2570UNTIL K%>=L%-1 OR char=quote |
| 2610ENDPROC | 2580ENDPROC |
| 2620 | 2590 |
| 2630 | 2600 |
| 2640REM PRINT A CHARACTER OR | 2610REM PRINT A CHARACTER OR |
| 2650REM COMPRESSED CODE | 2620REM COMPRESSED CODE |
| 2621REM Logical variable decode | |
| 2622REM indicates whether in program | |
| 2623REM or text mode - teletext codes | |
| 2624REM >128 can clog up the printer, | |
| 2625REM so for neatness' sake, replace | |
| 2626REM them by spaces. | |
| 2627REM DEF PROC and FN statements are | |
| 2628REM printed double width, so be | |
| 2629REM careful about the line length. | |
| 2660 | 2630 |
| 2670DEF PROCprint(char,decode) | 2640DEF PROCprint(char,decode) |
| 2680LOCAL l,A$ | 2650LOCAL l,A$ |
| 2690A$=CHR$(char) | 2660A$=CHR$(char) |
| 2700l=1 | 2670l=1 |
| 2710IF decode THEN IF char>printable THEN A$=NAME$(char-128):l=LEN(A$) | 2680IF decode THEN IF char>printable THEN A$=NAME$(char-128):l=LEN(A$) |
| 2720IF NOT decode THEN IF (char MOD 128)<space THEN A$=" " | 2690IF NOT decode THEN IF (char MOD 128)<space THEN A$=" " |
| 2730IF Q%+l*mode>R% THEN PROCstartline | 2700IF Q%+l*mode>R% THEN PROCstartline |
| 2740IF char=define THEN VDU 8,129:IF LEFT$(Y1$,1)="Y" THEN mode=double:VDU 1,32,1,14 | 2710IF char=define THEN VDU 8,129:IF LEFT$(Y1$,1)="Y" THEN mode=double:VDU 1,32,1,14 |
| 2750PRINT A$; | 2720PRINT A$; |
| 2760Q%=Q%+l*mode | 2730Q%=Q%+l*mode |
| 2770ENDPROC | 2740ENDPROC |
| 2780 | 2750 |
| 2790 | 2760 |
.