CURRENT NOTES NOVEMBER 1987 PASCAL FOR THE ATARI 8 BIT by Alan Friedman One of the members of our user group brought up the fact that many text files on bulletin boards and disks are too long to fit into a word processor and will not print out with page breaks and sufficient margins using the DOS C command. Therefore a program that would take a text file and break it up into smaller segments was needed. I started writing this program in Pascal and discovered a problem closing the smaller files. After calling Kyan I found you have to open a file and write all data to the new file inside of a procedure. This includes decalaring all VAR's that are used as local variables in the procedure. If this is done properly the file will close itself when the procedure is exited and all local variables are reset. This program is now on the Language #11, Pascal Sampler, XL/XE PD disk. PROGRAM SegFile(Input,Output,InFile,OutFile); (*this program will divide a text file that is too large for a word processor*) (*into several shorter files of between six and seven thousand letters.*) (*the new files will have the same name as the original file except that the*) (*extender will be changed to .Fx with x being the number of subfiles created*) (*Written by Alan Friedman 9/17/87*) (* Revised *) CONST MAXSTRING=15; (*String Length*) MAXEL=6000; TYPE String=ARRAY[1..MAXSTRING] OF Char; VAR Filename:String;(*Name of file to be segmented*) BlockNo,(*Counter for number or segements*) LetterCount:Integer;(*Counts the number of letters read*) Ch:Char;(*Character to be read*) Infile:Text;(*The file being read will be text*) XL 1 - XE CURRENT NOTES NOVEMBER 1987 LetterArray:ARRAY[1..7000] OF Char; (*Array for letters read to be stored in*) #i Length.i (*include the length function from disk*) PROCEDURE GetBlock; (*this procedure gets a block of seven thousand letters and then looks for the end of file of a carriage return and then transfers the data to disk*) VAR i,j,k,L:Integer;(*local counters*) OutFileName:String; (*the name of the file segment is written to*) OutFile:Text;(*Output to file will be text*) BEGIN IF BlockNo>0 THEN BEGIN Writeln('Put SOURCE DISK in Drive #1 and '); Writeln('press RETURN '); Readln; END; BlockNo:=BlockNo+1;(*Increase block count*) LetterCount:=0;(*Reset lettercount to zero*) i:=1;(*set local counter to 1*) WHILE (FileName[i]<>'.') AND (i'.')) DO BEGIN LetterCount:=LetterCount + 1; IF EOLN(InFile) THEN BEGIN Ch:=Chr(155); Readln(infile) END ELSE Read(Infile,Ch); IF LetterCount MOD 20 = 0 THEN Write('+'); LetterArray[LetterCount]:=Ch; END; Write(Chr(125)); Writeln('Put DESTINATION DISK in Drive #1'); Writeln('and press RETURN'); Readln; FOR j:= 1 to LetterCount DO BEGIN IF LetterArray[j]=Chr(155) THEN BEGIN Writeln(Outfile); Writeln END ELSE BEGIN Write(LetterArray[j]); Write(OutFile,LetterArray[j]); END; END; Writeln(Chr(125)); END; (*procedure GETBLOCK*) BEGIN (*program segfile*); BlockNo:=0; Writeln(Chr(125)); Writeln('Place SOURCE disk in DRIVE #1'); Writeln('What is the name of the file to be '); Writeln('segmented.'); XL 3 - XE CURRENT NOTES NOVEMBER 1987 Readln(Filename); Writeln; Reset(InFile,Filename); WHILE NOT EOF(InFile) DO BEGIN GetBlock; END; END. XL 4 - XE gments) and which are not erased after