home *** CD-ROM | disk | FTP | other *** search
- { DLST 1.1 - David L. Peterson, 220 9th St So. Waite Park, Mn 56387 }
- Uses Dos;
- type str255 = string[255];
- const
- sptab : array[0..9] of string[8] =
- (' ',' ',' ',' ',' ',' ',' ',' ',' ',' ');
- var
- inf,outf : text;
- inbuf,outbuf : array[1..10240] of char;
- fnm,infname : string[60];
- wln : string[255];
- lnr : integer;
- pgnr : integer;
- blanknr:integer;
- colnr: integer;
-
- r : real; { following used in setting lines per page }
- rss : string[5];
- err : integer;
- mxln : integer;
-
- {------------------------------------------}
- function intss(n,l:integer):str255;
- var ss : str255;
- begin
- str(n:l, ss);
- intss := ss;
- end;
-
- {------------------------------------------}
- { readln version of getline
- expands tabs, delete ff
- note: readln interprets a single CR as an end of line
- readln does not do anything special with a FF }
- procedure getline;
- var i,j : integer;
- begin
- readln(inf,wln);
-
- i := pos(#12,wln);
- while i <> 0 do begin
- delete(wln, i, 1);
- i := pos(#12,wln);
- end;
-
- i := pos(#9,wln);
- while i <> 0 do begin
- j := 9 - (i mod 8);
- delete(wln, i, 1);
- insert(sptab[j], wln, i);
- i := pos(#9,wln);
- end;
- end;
-
- {------------------------------------------}
- procedure prthdg;
- begin
- writeln(outf,
- #13#27'&dD',infname, { CR, Underline, File Name }
- #27'&a70C', { Pos to col 70 }
- 'Page',intss(pgnr,4), { Page number }
- #27,'&d@'); { Underline off }
- lnr := 2;
- writeln('Printing Page ', pgnr);
- end;
-
- {------------------------------------------}
- procedure endcol;
- begin
- if colnr = 1 then begin
- { Draw a rule between the two columns
- then position to line 0 }
- write(outf,#27'*p1230x0Y'#27'*c3a3150b0P'#27'&a0R');
- { Set font to internal 10 cpi font so we can set
- the left margin based on 1/10 in. }
- { 0p fixed spacing
- 10h 10 cpi
- 10u symbol set
- 3t Courier }
- { set left margin to 4.2 in., set to font id #1 }
- write(outf,#27'(s0p10h10u3T'#27'&a42L');
- write(outf,#27'(1X');
- colnr := 2;
- lnr := 1;
- end
- else begin
- { output a FF
- set to 10cpi font, set left margin to .4 in.
- set font id # 1, pos to line 0 }
- write(outf,#12);
- write(outf,#27'(s0p10h10u3T'#27'&a4L');
- write(outf,#27'(1X'#27'&a0R');
- colnr := 1;
- pgnr := pgnr + 1;
- prthdg;
- end;
- end;
-
- {------------------------------------------}
- procedure putline;
- var wlen : integer;
- begin
-
- wlen := length(wln);
- if wlen > 90 then lnr := lnr + 2
- else lnr := lnr + 1;
-
- if lnr >= mxln then
- endcol;
-
- if wlen > 90 then begin
- writeln(outf,#13#10,copy(wln,1,90));
- write (outf,' ....',copy(wln,91,80));
- end
- else
- write(outf,#13#10,wln);
- end;
-
- {------------------------------------------}
- begin
- writeln('DLST 1.1');
- pgnr := 1;
- colnr := 1;
-
- if paramcount < 2 then begin
- writeln('Usage: dlst <infile> <outfile> [# lines]');
- halt;
- end;
-
- { --- get lines per page & calc x/48 spacing --- }
- { --- default to 168 & 3.0/48 in. spacing --- }
- err := 1;
- if paramcount > 2 then
- val (paramstr(3), mxln, err);
- if err <> 0 then mxln := 168;
- r := trunc(5040/mxln)/10; { 504 is 10.5 in times 48 }
- str(r:3:1,rss);
-
- fnm := paramstr(1);
- assign(inf,fnm);
- SetTextBuf(inf,inbuf);
- {$I-} reset(inf); {$I+}
- if ioresult <> 0 then begin
- writeln(fnm, ' not found');
- halt;
- end;
- infname := fnm;
-
- fnm := paramstr(2);
- assign(outf,fnm);
- SetTextBuf(outf,outbuf);
- {$I-} rewrite(outf); {$I+}
- if ioresult <> 0 then begin
- writeln(fnm, ' cannot open');
- halt;
- end;
-
- { ---------- Send Esc Seqs to Printer ------------ }
- write(outf,#27'E', { reset }
- #27'&l8d2e84f6d', { set top & bottom margin to give
- 10.5 in of printable area }
- #27'(s0p10h10u3T'#27'&a4L',{ set to 10 cpi font,
- set left margin .4 in }
- #27'(1X', { set to font id # 1 }
- #27'&l',rss,'C', { set line spacing to rss/48 in. }
- #27'&a0R'); { position to line 0 }
-
- prthdg;
-
- { ---- Read & Print File ---- }
- blanknr := 0;
- while not eof(inf) do begin
- getline;
- if length(wln) = 0 then
- blanknr := blanknr + 1
- else
- blanknr := 0;
- if blanknr < 3 then
- putline;
- end;
-
- if lnr > 1 then
- write(outf,#12); { output FF }
-
- write(outf,#27'E'); { output Reset }
-
- close(inf);
- close(outf);
- end.