10
20
30
40
50 :
60
70 lpp%=60:
80 wid%=57:
90 mar%=60:
100 :
110 INPUT"Source file: "in$:in%=OPENIN(in$):IFin%=0:PRINT"'"in$"'" not found":END
120 INPUT"Dest. file: "out$:out%=OPENOUT(out$):IFout%=0:PRINT"Can't open '"out$"'":CLOSE#in%:in%=0:END
130 ON ERROR REPORT:PROCClose:PRINT:END
140 pg%=1:REPEAT:ptr1%=PTR#in%:FORl%=1 TO lpp%
150 PRINT"Page: ";pg%;", ";l%;" ";CHR$13;
160 IFNOTEOF#in%:REPEATUNTILBGET#in%=13 OR EOF#in%
170 NEXT:ptr2%=PTR#in%:top%=ptr2%:pg%=pg%+1
180 FORl%=1 TO lpp%:x%=0:PTR#in%=ptr1%
190 PRINT"Page: ";pg%;", ";l%;" ";CHR$13;
200 REPEATIFNOTEOF#in%:c%=BGET#in%:IFc%=13 OR c%>31:BPUT#out%,c%:x%=x%+1
210 UNTILc%=13 OR x%>wid% OR EOF#in%:IFc%=13:PTR#out%=PTR#out%-1 ELSE x%=x%+1
220 ptr1%=PTR#in%:FORx%=x% TO mar%:BPUT#out%,32:NEXT
230 c%=0:x%=0:IFNOTEOF#in%:PTR#in%=ptr2%
240 REPEATIFNOTEOF#in%:c%=BGET#in%:IFc%=13 OR c%>31:BPUT#out%,c%:x%=x%+1
250 UNTILc%=13 OR x%>wid% OR EOF#in%:IFc%<>13:BPUT#out%,13
260 ptr2%=PTR#in%:NEXT:IFptr1%=top% GOTO 310
270 PTR#in%=ptr1%:REPEATx%=0
280 REPEATc%=BGET#in%:IFc%=13 OR c%>31:BPUT#out%,c%:x%=x%+1
290 UNTILc%=13 OR x%>57:IFc%<>13:BPUT#out%,13
300 UNTILPTR#in%=top%:PTR#in%=ptr2%
310 BPUT#out%,12:pg%=pg%+1:UNTILEOF#in%
320 CLOSE#out%:out%=0:CLOSE#in%:in%=0:END
330 :
340 DEFPROCClose:IFin%:A%=in%:in%=0:CLOSE#A%
350 IFout%:A%=out%:out%=0:CLOSE#A%
360 ENDPROC