5 WIDTH "LPT1:",180
10 LPRINT CHR$(27)"@";
20 LPRINT CHR$(27)"2";
25 LPRINT CHR$(27)"O";
30 E$=CHR$(27)
35 F6P = 0: F2P = 0: 
40 ONN$(2)=E$+CHR$(87)+CHR$(1) : OFFF$(2)=E$+CHR$(87)+CHR$(0)
50 ONN$(3)=E$+CHR$(69)         : OFFF$(3)=E$+CHR$(70)
60 ONN$(4)=E$+CHR$(52)         : OFFF$(4)=E$+CHR$(53)
70 ONN$(5)=E$+CHR$(48)         : OFFF$(5)=E$+CHR$(50)
80 ONN$(6)=E$+CHR$(70)+CHR$(15): OFFF$(6)=CHR$(18)
90 ONN$(7)=E$+CHR$(71)         : OFFF$(7)=E$+CHR$(72)
100 ONN$(8)=E$+CHR$(45)+CHR$(1): OFFF$(8)=E$+CHR$(45)+CHR$(0)
105 LPI = 6 : DOTS.INCH=216
110 INPUT "Set the printer to the top of the page. Ready";C$
112 INPUT "COMMAND INDICATOR CHARACTER";Q$
114 IF C$ ="s" THEN STD = 1 ELSE STD = 0 :INPUT "lines per inch (d=6)";LPI
115 IF LPI = 0 THEN LPI = 6
116 IF NOT LPI=6 THEN XLPL=DOTS.INCH\LPI: OFFF$(5)=E$+CHR$(51)+CHR$(XLPL): ONN$(5)=OFFF$(5)
117 PRINT XLPL: IF NOT LPI = 6 THEN LPRINT OFFF$(5);
118 LENGTH = 66: LINE.LENGTH = 68
120 IF STD = 0 THEN INPUT "How many lines per page (d=66)";LENGTH
125 IF LENGTH = 0 THEN LENGTH = 66
130 IF STD = 0 THEN INPUT "what`s the line length (d=68)";LINE.LENGTH
135 IF LINE.LENGTH = 0 THEN LINE.LENGTH = 68
170 PAGE = 1:  SECTION.C$ = " ": ZZ$="a"
180 INPUT "Do you want lettered sections (Y or N)";SECT$
190 IF NOT(SECT$="Y" OR SECT$="y") THEN SECT$="-": GOTO 250
200 INPUT "What letter should I start with?  (1=`A' 2=`B' etc.)";S.N
205 IF S.N = 0 THEN S.N = 1
210 SECTION.N = 64+S.N
220 SECTION.C$ = CHR$(SECTION.N)
230 SECT$ = " "
250 LPRINT CHR$(27)"C"CHR$(LENGTH);
255 T.START = 6: T.END = 59: PAGE.LINE = 63: M.L = 8
260 IF STD = 0 THEN INPUT "On which line does the text begin (d=6)";T.START
265 IF T.START = 0 THEN T.START = 6
270 IF STD = 0 THEN INPUT "On which line does it end (d=59) ";T.END
275 IF T.END = 0 THEN T.END = 59
280 PITCH = 10
281 IF NOT STD = 0 THEN GOTO 290
282 INPUT "How many columns for left margin (d=8)";M$
283 IF M$="" THEN M.L = 8 ELSE M.L = VAL(M$)
285 IF NOT ((LINE.LENGTH + M.L) > 78) THEN GOTO 290
286 LINE.LENGTH = LINE.LENGTH - 1
287 GOTO 285
290 PARA.INDENT = 5: CC.ON.BUF = 0
300 TLINES = T.END - T.START + 1
310 MARG.BOT = LENGTH - T.END
320 LYNE = 1
330 FOR I=0 TO 8: FLAG(I)=0: NEXT I
340 MARG.TOP = T.START - 1
350 FOR I=1 TO MARG.TOP
360 LYNE = LYNE + 1 :LPRINT
370 NEXT I
380 MODE = 1: TEXT.COUNT = 0: BUFFER$ = "": LAST.TEXT$ = " "
385 T.IN.LINE = 0: L.ON = 1
390 IF STD = 0 THEN INPUT "On which line do you want the page numbers";PAGE.LINE
400 INPUT "What is the name of your file"; FILE$
410 '
420 OPEN FILE$ FOR INPUT  AS #1
430 '
440 '
460 ' SUBROUTINE NEW-LINE
470 '
480 IF EOF(1) THEN GOSUB 1360:GOSUB 1570: CLOSE: LPRINT CHR$(27)"@":END
490 CC.CODE = 1
500 LINE INPUT  #1,C$
510 LEN.C = LEN(C$)
520 IF NOT (LEN.C=0) THEN GOTO 550
530 IF FLAG (0) = 1 THEN GOSUB 1360
540 GOTO 460
550 LASTC$=RIGHT$(C$,1)
560 IF LASTC$ = " " THEN C$=LEFT$(C$,LEN.C-1): GOTO 510
570 FIRSTC$=LEFT$(C$,1)
580 IF (FLAG(0)=1) OR (NOT(FIRSTC$=" ")) THEN GOTO 620
590 LEN.C = LEN(C$)
600 C$ = RIGHT$(C$,LEN.C -1)
610 IF LEN.C =1 THEN GOTO 460 ELSE GOTO 570
620 IF FIRSTC$=Q$ THEN GOSUB 670 ELSE  GOSUB 760
630 IF NOT(LEN(C$) = 0) THEN GOTO 570
640 IF FLAG(0) = 1 THEN GOSUB 1360
650 GOTO 460
660 '
670 ' Subroutine control character
680 '
690 L.LEN = LEN(C$)
700 CC.CHAR$=MID$(C$,2,1)
705 IF CC.CHAR$=" " THEN GOTO 742
710 L.LEN = L.LEN -2
720 IF L.LEN>0 THEN C$=RIGHT$(C$,L.LEN) ELSE C$="" '  removes control character
730  GOSUB 1810  ' send control char to buffer
740 RETURN
741 '  here is a literal "!". keep it as text.
742 E.MARK$ = LEFT$(C$,2)
743 BUFFER$=BUFFER$ + E.MARK$
744 TEXT.COUNT = TEXT.COUNT + 2
745 L.LEN = L.LEN - 2
746 IF L.LEN>0 THEN C$=RIGHT$(C$,L.LEN) ELSE C$="" '  removes control character
747 RETURN
750 '
760 ' Subroutine accumulate good text from line
770 '
780 L.LEN = LEN (C$)
790 FOR I=1 TO L.LEN
800 IF MID$(C$,I,1) = Q$ THEN GOTO 870
810 NEXT I
820 TEXT$=C$
830 IF FLAG(1) = 1 THEN C$ = "":  RETURN '  if this is a centering line...
840 GOSUB 950' send text to buffer
850 C$=""
860 RETURN
870 ' (there's a cc.char in the string...)
880 TEXT$=LEFT$(C$,I-1)
890 L.LEN = L.LEN -I+1
900 C$=RIGHT$(C$,L.LEN)
910 IF FLAG(1) = 1 THEN RETURN
920 GOSUB 950'  send text to buffer
930 RETURN
940 '
950 'Subroutine text buffer
960 '
970 IF (TEXT.COUNT + (LEN(TEXT$)*10/PITCH) > LINE.LENGTH - 1) THEN GOTO 1070
980 TEXT.COUNT = TEXT.COUNT + (LEN(TEXT$)*10/PITCH)' add text to buffer
990 IF (LAST.TEXT$ = " " AND LEFT$(TEXT$,1) = " " AND FLAG(0)=0) THEN                   TEXT$ = RIGHT$(TEXT$,LEN(TEXT$) -1): ELSE GOTO 1010
1000 GOTO 990
1010 IF NOT (LAST.TEXT$ = " " OR LEFT$(TEXT$,1) = " ") THEN                        BUFFER$=BUFFER$ + SPACE$(1): TEXT.COUNT = TEXT.COUNT + PITCH/10
1020 BUFFER$=BUFFER$+TEXT$: T.IN.LINE = 1
1030 LAST.TEXT$= RIGHT$(BUFFER$,1)
1040 TEXT$ = ""
1050 RETURN' buffer isn't full yet.
1060 '
1070 GOSUB 1180 'find the max amount of text that fits
1080 IF NOT(LAST.TEXT$=" " OR LEFT$(MAX.TEXT$,1) = " ") THEN                            BUFFER$=BUFFER$ + SPACE$(1)
1090 BUFFER$=BUFFER$ + MAX.TEXT$: T.IN.LINE =1'--fill the buffer with amap
1100 LAST.TEXT$ = RIGHT$(BUFFER$,1)
1110 GOSUB 1360: L.ON = 0
1120 IF NOT(LYNE > T.END) THEN GOTO 1140
1130 GOSUB 1570: GOSUB 1710
1140 IF LEN(TEXT$) >0 THEN GOTO 970
1150 RETURN
1160 ' end text buffer
1170 '
1180 'Subroutine find the max amount of text that fits
1200 SPACE = LINE.LENGTH - TEXT.COUNT'-- this is the space available at EOL
1210 SPACE = SPACE * PITCH/10
1215 IF FLAG(0) = 1 THEN GOTO 1280
1220 FOR I=SPACE TO 1 STEP -1'   ----------\
1230 M$=MID$(TEXT$,I,1)
1240 IF M$=" " OR M$= "-" THEN GOTO 1320'  >- find a blank in the string
1250 NEXT I' ------------------------------/
1260 MAX.TEXT$= ""
1270 IF FLAG(0)=0 THEN RETURN
1280 MAX.TEXT$=TEXT$
1290 PRINT "pre-formatted line is too long." TEXT$
1300 INPUT "continue";Z$
1310 TEXT$ = "": RETURN
1320 MAX.TEXT$=LEFT$(TEXT$,I)'---this is as much as can be added to buffer
1330 TEXT$=RIGHT$(TEXT$,LEN(TEXT$)-I)'--this is what's left.
1340 RETURN
1350 '
1360 ' Subroutine print buffer and initialize it again
1370 '
1380 IF (FLAG(1)=1 OR FLAG(0)=1) THEN BLANKS=M.L ELSE BLANKS = INDENT+M.L
1382 DS$ = "": IF F2P=1 THEN DS$ = DS$ + ONN$(2)
1384           IF F6P=1 THEN DS$ = DS$ + ONN$(6)
1386 DSO$="": IF F2P=1 THEN DSO$ = DSO$ + OFFF$(2)
1388          IF F6P=1 THEN DSO$ = DSO$ + OFFF$(6)
1400 LPRINT DSO$;SPACE$(BLANKS);DS$; BUFFER$
1410 BUFFER$="": CC.ON.BUF = 0: T.IN.LINE = 0
1420 LAST.TEXT$ = " ": CENTER = 0
1430 IF FLAG(0)=1 OR FLAG(1)=1 THEN TEXT.COUNT = 0 ELSE TEXT.COUNT = INDENT
1440 LYNE = LYNE + 1
1445 F6P = FLAG(6): F2P = FLAG(2)
1450 IF NOT(LYNE > T.END) THEN RETURN
1460 IF P.END = 1 THEN P.END =0: RETURN   ELSE GOSUB 1570: GOSUB 1710
1470 RETURN
1480 '
1490 '
1500 'Subroutine stick control character on buffer
1510 '
1520 IF FLAG(CODE.NUMBER)=1 THEN BUFFER$=BUFFER$ + ONN$(CODE.NUMBER)                    ELSE BUFFER$ = BUFFER$ + OFFF$(CODE.NUMBER)
1530 CC.ON.BUF = CC.ON.BUF + 3
1540 RETURN
1550 '
1560 '
1570 'Subroutine go to the top of the next page
1580 '
1590 IF LYNE > T.END THEN GOTO  1640' take care of new page
1600 TOSKIP = T.END - LYNE
1610 FOR I=1 TO TOSKIP : LPRINT
1620 LYNE = LYNE + 1
1630 NEXT I
1640 FOR I = 1 TO MARG.BOT
1650 IF LYNE = PAGE.LINE THEN GOSUB 2870 ELSE LPRINT : LYNE=LYNE+1
1660 NEXT I
1670 PAGE = PAGE + 1
1680 RETURN
1690 '
1700 '
1710 ' subroutine top of new page
1720 IF NOT (ZZ$="") THEN INPUT "new page. ready?";ZZ$
1730 LYNE = 1
1740 FOR I = 1 TO MARG.TOP
1750 IF I= PAGE.LINE THEN GOSUB 2870 ELSE LPRINT :LYNE=LYNE+1
1760 NEXT I
1770 RETURN
1780 'END  (newpage)
1790 '
1800 '
1810 'Subroutine special code mode
1820 '
1830 IF NOT(CC.CHAR$= "*") THEN GOTO 1870
1840 IF TEXT.COUNT > 0 THEN GOSUB 1360
1850 IF FLAG(0) = 1 THEN FLAG(0) = 0:L.ON =1: ELSE FLAG(0) = 1: L.ON = 0
1860  RETURN
1870 V = VAL (CC.CHAR$)
1880 IF CC.CHAR$ = "0" THEN GOTO 1900
1890 IF NOT (0 < V  AND V < 7) THEN GOTO 1930' \___ handle indentation
1900 IF TEXT.COUNT > 0 THEN GOSUB 1360: L.ON = 1
1910 INDENT = 5 * VAL(CC.CHAR$)
1920 TEXT.COUNT = INDENT*10/PITCH  : RETURN
1930 IF NOT(CC.CHAR$ = "p" OR CC.CHAR$ = "P") THEN GOTO 1990
1940 IF T.IN.LINE = 1 THEN GOSUB 1360 :L.ON=0 :ELSE GOTO 1970
1950    BUFFER$ = BUFFER$ + SPACE$(PARA.INDENT)
1960    TEXT.COUNT = PARA.INDENT * 10/PITCH + TEXT.COUNT: RETURN
1970 'IF L.ON = 1  THEN GOSUB 1360
1980 'L.ON = 1
1985 GOTO 1950
1990 IF NOT(CC.CHAR$ = "L" OR CC.CHAR$="l") THEN GOTO 2020
2000 IF T.IN.LINE = 1 OR L.ON = 1 THEN GOSUB 1360
2010 L.ON = 1 : RETURN
2020 IF NOT (CC.CHAR$="!") THEN GOTO 2060
2030 IF TEXT.COUNT > INDENT THEN GOSUB 1360
2040 GOSUB 1570: GOSUB 1710
2050 L.ON = 1: RETURN
2060 IF NOT (CC.CHAR$="?") THEN GOTO 2100
2070 LINES.LEFT = T.END-LYNE
2080 IF LINES.LEFT < 10 THEN RETURN ELSE GOTO 2030
2090 RETURN
2100 IF NOT (CC.CHAR$="C" OR CC.CHAR$="c") THEN GOTO 2120 ELSE GOSUB 2270
2110  RETURN 'special code mode
2120 IF NOT (CC.CHAR$="$") THEN GOSUB 2460 ELSE GOSUB 2160
2130 RETURN
2140 '
2150 '
2160 'Subroutine next section
2170 '
2180 IF SECT$= "-" THEN RETURN
2190 GOSUB 1570
2200 PAGE = 1
2210 SECTION.N = SECTION.N + 1
2220 SECTION.C$ = CHR$(SECTION.N)
2230 GOSUB 1710
2240 RETURN
2250 '
2260 '
2270 ' Subroutine center the line
2280 '
2290 COLS = PITCH * (LINE.LENGTH/10)
2295 'IF CENTER = 1 THEN GOTO 2310
2300 IF T.IN.LINE > 0 THEN GOSUB 1360: L.ON =0'-- print the buffer
2305 IF CENTER = 1 THEN GOTO 2310
2310 TEXT.COUNT = 0
2320 FLAG(1) = 1
2330 GOSUB 760'---get text up to next Q$
2340 IF LEN(TEXT$) > LINE.LENGTH  THEN GOSUB 1180                                            ELSE MAX.TEXT$ = TEXT$ : TEXT$ = ""
2350 TOSKIP = (COLS -LEN(MAX.TEXT$))/2 '  compute leading blanks
2360 BUFFER$ = BUFFER$ + SPACE$(TOSKIP) '  add the blanks to buffer
2370 BUFFER$ = BUFFER$ + MAX.TEXT$: T.IN.LINE = 1'---add text to buffer
2380 LAST.TEXT$ = " "
2390 GOSUB 1360'-- print the line
2400 IF LEN(TEXT$)>0 THEN GOTO 2340
2410 FLAG(1) =0 : L.ON = 1: CENTER=1
2420 RETURN
2430 END' (SUBROUTINE SPECIAL CODE MODE)
2440 '
2450 '
2460 'Subroutine decode cc.char and send codes to buffer
2470 '
2480 IF NOT(CC.CHAR$="@") THEN GOTO 2530
2490 FOR I = 2 TO 8
2500    FLAG(I) = 0: BUFFER$ = BUFFER$ + OFFF$(I)
2510    NEXT I
2520    GOTO 2810
2530 IF NOT (CC.CHAR$="E" OR CC.CHAR$="e") THEN GOTO 2560                                 ELSE IF (CC.CHAR$="E") THEN FLAG(3) = 1  ELSE FLAG(3) = 0
2540 CODE.NUMBER = 3:  GOSUB 1490'  get buffer fixed
2550                            GOTO 2810
2560 IF NOT (CC.CHAR$="D" OR CC.CHAR$="d") THEN GOTO 2590                                ELSE IF (CC.CHAR$="D") THEN FLAG(2) = 1  ELSE FLAG(2) = 0
2570 CODE.NUMBER = 2: GOSUB 1490'  get buffer fixed
2580                            GOTO 2810
2590 IF NOT (CC.CHAR$="I" OR CC.CHAR$="i") THEN GOTO 2620                                ELSE IF (CC.CHAR$="I") THEN FLAG(4) = 1  ELSE FLAG(4) = 0
2600 CODE.NUMBER = 4: GOSUB 1490'  get buffer fixed
2610                            GOTO 2810
2620 IF NOT (CC.CHAR$="N" OR CC.CHAR$="n") THEN GOTO 2650                                ELSE IF (CC.CHAR$="N") THEN FLAG(5) = 1   ELSE FLAG(5) = 0
2630 CODE.NUMBER = 5: GOSUB 1490' get buffer fixed
2640                            GOTO 2810
2650 IF NOT (CC.CHAR$="T" OR CC.CHAR$="t") THEN GOTO 2680                                ELSE IF (CC.CHAR$="T") THEN FLAG(7) = 1 ELSE FLAG(7) = 0
2660 CODE.NUMBER = 7: GOSUB 1490' get buffer fixed
2670                            GOTO 2810
2680 IF NOT (CC.CHAR$="U" OR CC.CHAR$="u") THEN GOTO 2710                                ELSE IF (CC.CHAR$="U") THEN FLAG(8) = 1 ELSE FLAG(8) = 0
2690 CODE.NUMBER = 8: GOSUB 1490' get buffer fixed
2700                            GOTO 2810
2710 IF NOT (CC.CHAR$="S" OR CC.CHAR$="s") THEN GOTO 2740                                ELSE IF (CC.CHAR$="S") THEN FLAG(6) = 1 ELSE FLAG(6) = 0
2720 CODE.NUMBER = 6: GOSUB 1490' get buffer fixed
2730                            GOTO 2810
2740 IF NOT (CC.CHAR$="X")THEN FLAG(9)=0: GOTO 2790 ELSE FLAG(9)=1
2750 XC$=LEFT$(C$,2) : LEN.C = LEN(C$) - 2 : C$ = RIGHT$(C$,LEN.C)
2760 XX = VAL (XC$)
2770 BUFFER$=BUFFER$ + CHR$(XX)
2780 RETURN
2790 PRINT "I don't recognize this print control character: ";CC.CHAR$
2800 RETURN
2810 '
2820 PITCH = 10
2830 IF FLAG(6) = 1 THEN PITCH =  17
2840 IF FLAG(2) = 1 THEN PITCH = 5
2850 RETURN
2860 '
2870 ' PAGENUMBER
2880 '
2890 P.END = 1
2900 FOR J = 2 TO 8: BUFFER$= BUFFER$ + OFFF$(J): NEXT J
2910 PN = LINE.LENGTH /2 - 2
2920 BUFFER$=BUFFER$ + SPACE$(PN)
2930 BUFFER$=BUFFER$ + ONN$(3)+ONN$(7)+SECTION.C$ +" -" + STR$(PAGE)+SECT$
2940 GOSUB 2980
2950 BLANKS = 8: GOSUB 1400' PRINT BUFFER OUT AND EMPTY
2960 RETURN
2970 '
2980 ' Subroutine reset old cc.codes in new buffer
2990 '
3000 FOR K=2 TO 8
3010    IF FLAG(K) = 1 THEN BUFFER$ = BUFFER$ + ONN$(K)                                    ELSE BUFFER$ = BUFFER$ + OFFF$(K)
3020 NEXT K
3030 RETURN
EN BUFFER$ = BUFFER$ + ONN$(K)                                    ELSE BUFFER$ = BUFFER$ + OFFF$(K)
3020 N