procedure typefile(fname: longname; nowrap: boolean); {Inline unsqueezer adapted from USQ.PAS V1.3, which was written by Scott Loftesness, adapted for Turbo Pascal by Steve Freeman and made compatible with Non-Turbo Pascal squeezers by myself.- BM} const recognize = $FF76; numvals = 257; { max tree size + 1 } speof = 256; { special end of file marker } dle: char = #$90; type tree = array [0..255,0..1] of integer; var in_ptr, result: integer; in_buff: filbuffer; dnode: tree; inchar, curin, filecksum, bpos, i, repct, numnodes: integer; c, lastchar: char; origfile: name; squeezed, eofin: boolean; function getc: integer; begin in_ptr := in_ptr + 1; if in_ptr > 127 then begin if libeof then eofin := true else begin libblockread(in_buff); in_ptr := 0; end; end; if eofin then getc := 26 else getc := in_buff[in_ptr]; end; function getw: integer; var in1,in2: integer; begin in1 := getc; in2 := getc; getw := in1 + in2 shl 8; end; procedure initialize; var str: string[14]; begin in_ptr := 127; squeezed := true; outl := ''; repct:=0; bpos:=99; origfile:=''; eofin:=false; i := getw; if (recognize <> i) then begin squeezed := false; in_ptr := -1; end else begin filecksum := getw; { get checksum from chars 2 - 3 of file } repeat { build original file name } inchar:=getc; if inchar <> 0 then origfile := origfile + chr(inchar); until inchar = 0; writeln(dev,'Original file: ' + origfile); numnodes:=ord(getw); { get the number of nodes in this files tree } if (numnodes<0) or (numnodes>=numvals) then begin squeezed := false; in_ptr := -1; end; end; if squeezed then begin dnode[0,0]:= -(speof+1); dnode[0,1]:= -(speof+1); numnodes:=numnodes-1; for i:=0 to numnodes do begin dnode[i,0]:=getw; dnode[i,1]:=getw; end; end; end; function getuhuff: char; var i: integer; begin i:=0; repeat bpos:=bpos+1; if bpos>7 then begin curin := getc; bpos:=0; end else curin := curin shr 1; i := ord(dnode[i,ord(curin and $0001)]); until (i<0); i := -(i+1); if i=speof then begin eofin:=true; getuhuff:=chr(26); end else getuhuff:=chr(i); end; function getcr: char; var c: char; begin if squeezed then begin if (repct>0) then begin repct:=repct-1; getcr:=lastchar; end else begin c:=getuhuff; if c<>dle then begin getcr:=c; lastchar:=c; end else begin repct:=ord(getuhuff); if repct=0 then getcr:=dle else begin repct:=repct-2; getcr:=lastchar; end; end; end; end else getcr := chr(getc); end; {getcr} begin {typefile} libassign(fname, result); if result <> 0 then writeln('Can''t find ' + fname + '!') else begin initialize; if squeezed then lct := 1 else lct := 0; {linecounter for paged screens} fullct := lct; {total lines counter} D := 0; lptr := 0; if not(finding) then pause := true else pause := false; repeat while (lct < 23) and not(cancelled or eofin) do begin c:=getcr; if c = #26 then eofin := true else begin if nowrap then begin if c <> #$8D then begin { <-- Allows no-wrap using WordStar files} c := chr(ord(c)); { and 127); } if (c <> lnfd) then sendout(c); if c = cr then sendout(lnfd); lct := succ(lct); end; end else begin sendout(c); if (c = cr) or (c = #$8d) then begin if not(pause) and (conout) then delay(d); if keypressed then begin register_A := bdos(6,$FF); case chr(register_A) of ^[ : begin writeln(' Aborting search this file.'); exit; end; ^C : cancelled := true; ^X : pause := not(pause); '0'..'9' : begin case chr(register_A) of '0' : D := 0; '1' : D := 50; '2'..'8' : D := ((register_A - 49) * 200{150}); '9' : repeat until keypressed; end; {case} end; end; {case} end; lct := succ(lct); end; end; end; end; {while} if (lct = 23) then begin if ((not(finding)) and pause and conout) then begin writeln; write ('[more] : [^X pause on/off] : [0-9 scroll speed] : [^C quit] : [ skip]'); read(kbd,continue); case continue of ^[ : begin writeln; exit; end; ^C : cancelled := true; ^X : pause := not(pause); end; {case} { lct := succ(lct);} end; write(^M); fullct := fullct + lct; if lct = 23 then lct := 0; {clrscr;} end; until (cancelled or eofin); if eofin then begin fullct := fullct + lct; if (finding) then writeln(dev) ; if ((lct in [1..22]) and not(finding)) then begin repeat writeln; if not (pause) and (conout) then delay(D); lct:=succ(lct); until lct = 23; end; if (pos('/DIR',fname) = 0) and not(finding) then begin writeln(^G,'Done after ',fullct,' lines--press any key'); read(kbd,continue); end; close(libfile); end; {if eofin} end; end;