155. Splitting large files ~~~~~~~~~~~~~~~~~~~~~ This program was written in order to split a very large word-processing file that was too big to fit into memory. (Any type of file can be split; not just text files.) This may happen if the micro which saved the data had a 6502 2nd processor, Shadow RAM, or some other means of gaining memory, whereas yours may not. The program splits large files into smaller ones, whose length in bytes is determined by the variable max% in line 10. You should substitute the name of the large file for "oldname", and the name of the smaller subfiles for "newname". The subfile names will be suffixed by "1", "2" etc, so you will be limited to 6 characters on an ordinary DFS. This program will split a file in mid-word, so if you don't want it to do that, you can replace the expression PTR#c2=max% in line 40 with (PTR#c2>=max%ANDg%=32) ; the brackets are very important. This will split the file at the first available Space, but if you put 13 instead of 32, the file will be split at the first available Carriage Return, which would usually be at the end of a paragraph. Many refinements could be added, and the program is rather slow, but it does the job. 10 max%=15000:f%=1:c1=OPENIN("oldname") 20 REPEAT:c2=OPENOUT("newname"+STR$(f%)) 30 REPEAT:g%=BGET#c1:BPUT#c2,g% 40 UNTIL PTR#c2=max% OR EOF#c1:CLOSE#c2:f%=f%+1 50 UNTIL EOF#c1:CLOSE#c1