home *** CD-ROM | disk | FTP | other *** search
- { DLSTW 1.2 - David L. Peterson, 220 9th St So. Waite Park, Mn 56387 }
-
- { Print multiple files using very small font to get up to 336 lines
- printed per page
- }
-
- 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;
- i,j,k: integer;
- colnr: integer;
-
- wss : string[60];
- title: string[60];
-
- r : real; { following 3 used in setting lines per page }
- rss : string[5];
- err : integer;
- mxln : integer;
-
- {------------------------------------------}
- function reptch(ch:char; n:integer):str255;
- var ss : str255;
- begin
- if n > 0 then fillchar(ss[1],n,ch);
- ss[0] := chr(n);
- reptch := ss;
- end;
-
- {------------------------------------------}
- 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',title, { CR, Underline, Title }
- #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;
-
-
- {------------------------------------------}
- procedure pfile(fspec, fnm, fdesc:str255);
- begin
- assign(inf,fspec);
- SetTextBuf(inf,inbuf);
- {$I-} reset(inf); {$I+}
- if ioresult <> 0 then begin
- writeln(fnm, ' cannot open');
- halt;
- end;
-
- wln := '';
- putline;
- write(outf,#27'*c1000a3b0P');
-
- wln:=#27'&dD'+fnm+' '+fdesc+#27'&d@';
- putline;
-
- 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;
- close(inf);
- end;
-
- {--------------------------------------------------}
- { Getfnames - use wildcard name to process files }
- { fnm - wildcard filename }
- { pass - =1 then list filenames }
- { pass - =2 then process each file }
- {--------------------------------------------------}
- procedure getfnames (fnm:str255;pass:integer);
-
- var
- Dirinfo : Searchrec;
- Dttm : DateTime;
- sname : string[65];
- prefix : string[65];
- nm : string[12];
- szss,mdyss: string[12];
- j : integer;
- begin
-
- sname := fnm;
- if sname = '' then
- sname := '*.*';
-
- { --- get prefix(drive & path) of file spec if any --- }
- j := 0;
- for i := 1 to length(sname) do
- if sname[i] in [':','\'] then j := i;
- prefix := '';
- if j > 0 then
- prefix := copy(sname,1,j);
-
- Findfirst(sname, 0, Dirinfo);
-
- j := 0;
- while DosError = 0 do begin
- with Dirinfo do begin
- nm := Name;
-
- if ( pos('.COM',nm) = 0 )
- and ( pos('.EXE',nm) = 0 ) then begin
- UnpackTime(time,Dttm);
-
- with Dttm do
- mdyss := intss(month,2)+'/'+intss(day,2)+'/'+intss(year,2);
-
- str(Size:8, szss);
-
- if pass = 1 then begin
- wln := nm + reptch(' ',20-length(nm)) + mdyss + ' ' + szss;
- putline;
- end else
- pfile(prefix + nm, nm, mdyss + ' ' + szss);
- end;
-
- end; {with}
- FindNext (Dirinfo);
-
- end; {while}
- end;
- {------------------------------------------}
- begin
- writeln('DLSTW 1.2');
- pgnr := 1;
- colnr := 1;
-
- if paramcount < 3 then begin
- writeln('Usage: dlstw title <fspec> <outfile> [# lines]');
- halt;
- end;
-
- { --- get lines per page & calc x/48 spacing --- }
- { --- default to 168 & 3.0/48 in. spacing --- }
- err := 1;
- if paramcount > 3 then
- val (paramstr(4), 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);
-
- title := paramstr(1);
- wss := paramstr(2);
-
- fnm := paramstr(3);
- 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,
- ** add symbol set to font sel 10u
- 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 ---- }
- lnr := 1;
-
- getfnames(wss,1);
- getfnames(wss,2);
-
- { 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(outf);
- end.