10 REM >TSplit 0.02
   20 REM Split a text file into columns
   30 REM 25-05-1995 JGH: Original version
   40 REM 22-02-1997 JGH: Generalised
   50 :
   60 REM This gives two columns on 130 width
   70 lpp%=60:REM Lines per page
   80 wid%=57:REM Column width
   90 mar%=60:REM Second column starts here
  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