home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Jason Aller Floppy Collection
/
153.img
/
TELES.ZIP
/
TYPEW.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1988-04-04
|
6KB
|
224 lines
{$R-} {Range checking off}
{$B+} {Boolean complete evaluation on}
{$S+} {Stack checking on}
{$I+} {I/O checking on}
{$N-} {No numeric coprocessor}
{$M 65500,16384,655360}
program typew;
Uses
Crt;
type
str =string[255];
var
i,pap : integer;
filv:text;
filn:string[12];
n :string[255];
c :integer;
okansi,nofeed:boolean;
hangup:boolean;
nopfile:boolean;
nofile:boolean;
procedure centre(var i:str); (* Center I String *)
var n,n1:integer;
begin
if i[1]=#2 then i:=copy(i,2,length(i)-1);
n:=length(i); n1:=1;
while (n1<=length(i)) do begin
if i[n1]=#3 then begin
n:=n-2;
n1:=n1+1;
end;
n1:=n1+1;
end;
if n<80 then
i:=copy(' ',1,
(80-n) div 2)+i;
end;
procedure checkhangup;
begin
end;
procedure print(i:str);
begin
writeln(i);
end;
procedure prompt(i:str);
begin
write(i);
end;
procedure nl;
begin
writeln;
end;
procedure cl(i:integer);
begin
if i=0 then begin textcolor(15); textbackground(0); end;
if i=1 then begin textcolor(3); textbackground(0); end;
if i=2 then begin textcolor(1); textbackground(0); end;
if i=3 then begin textcolor(11);textbackground(0); end;
if i=4 then begin textcolor(9); textbackground(0);end;
if i=5 then begin textcolor(14);textbackground(0);end;
if i=6 then begin textcolor(15); textbackground(1); end;
if i=7 then begin textcolor(4); textbackground(0);end;
if i=8 then begin textcolor(12+16);textbackground(0);end;
if i=9 then begin textcolor(10);textbackground(0);end;
end;
procedure printa1(i:str; var abort,next:boolean); (* Print line of text *)
var c:integer;
begin
checkhangup;
if not hangup then begin
abort:=false; next:=false; c:=1;
while (not abort) and (c-1<length(i)) and (not hangup) do begin
checkhangup;
if (c-1<length(i)) then begin
if i[c]=chr(8) then begin
pap:=pap-1;
delay(30);
end else
if i[c]=#3 then begin
if i[c+1] in [#0..#9] then
if okansi then
cl(ord(i[c+1]));
end else
if i[c]<>chr(10) then pap:=pap+1;
if i[c]=#3 then
c:=c+1
else
if (i[c]<>#29) then write(i[c]);
c:=c+1;
end;
end;
end else abort:=true;
end;
procedure printa(i:str; var abort,next:boolean);
var s:str; p,op,rp,rop,nca:integer; crend:boolean;
begin
nofeed:=false;
abort:=false;
nopfile:=false;
crend:=(i[length(i)]=#1) and (i[length(i)-1]<>#3);
if i[length(i)]=#29 then nofeed:=true;
if crend then i:=copy(i,1,length(i)-1);
if i[1]=#2 then begin
centre(i);
printa1(i,abort,next);
nl;
end else begin
if i='' then nl;
while (i<>'') and (not abort) and (not hangup) do begin
rp:=0;
if pos(#27,i)=0 then nca:=80-pap-1 else nca:=255;
p:=0;
while (rp<nca) and (p<length(i)) do begin
if i[p+1]=#8 then rp:=rp-1 else
if i[p+1]=#3 then
p:=p+1
else
if (i[p+1]<>#10) then rp:=rp+1;
p:=p+1;
end;
op:=p; rop:=rp;
if (rp>=nca) and (p<length(i)) then begin
while ((not (i[p] in [' ',#8,#10])) or (i[p-1]=#3)) and (p>1) do begin
rp:=rp-1; p:=p-1;
end;
if p=1 then
if not (i[1] in [' ',#8,#10]) then begin rp:=rp-1; p:=p-1; end;
end;
if abs(rop-rp)>=(80 div 2) then p:=op;
s:=copy(i,1,p); delete(i,1,p);
if (s[length(s)]=' ') and not nofeed then s[0]:=pred(s[0]);
printa1(s,abort,next);
if ((i='') and crend) or (i<>'') or abort then
if (nofeed=false) then nl
else
IF NOFEED=FALSE THEN printa1(' ',abort,next);
end;
end;
end;
procedure printacr(i:str; var abort,next:boolean);
begin
if not abort then
if (i[length(i)]=#1) or (i[length(i)]=#29) then
printa(i,abort,next)
else
printa(i+#1,abort,next);
end;
procedure pfl(fn:str; var abort:boolean; cr:boolean);
var fil:text;
i:str;
ofn:str;
p:integer;
next:boolean;
begin
nofile:=false;
if not hangup then begin
assign(fil,fn);
{$I-} reset(fil); {$I+}
if ioresult<>0 then nofile:=true else
begin
abort:=false;
while not eof(fil) and (not abort) and (not hangup) and (nofile=false) do begin
readln(fil,i);
if cr then
printacr(i,abort,next)
else
printa(i,abort,next);
end;
close(fil);
end;
end;
nl;
end;
procedure printfile(fn:str); (* Print normal text file *)
var abort:boolean;
begin
pfl(fn,abort,true);
end;
begin
nofeed:=false;
nopfile:=false;
nofile:=false;
hangup:=false;
okansi:=true;
for i := 1 to ParamCount do
filn:=ParamSTR(i);
assign(filv,filn);
{$I-} reset(filv); {$I+}
if ioresult<>0 then begin
writeln;
textcolor(10);
writeln('TYPE WWIV - A DOS Utility Written By Carl Mueller');
textcolor(11);
writeln;
writeln('Command syntax as follows:');
writeln('TYPEW [d:][path][filename]');
writeln;
textcolor(15);
writeln('TYPEW was written in Turbo Pascal 4.0 and designed to list');
writeln('WWIV color coded files in DOS mode. This program will work');
writeln('also with software such as TELEGARD or TAG which uses the');
writeln('same format.');
writeln;
end else begin
printfile(filn);
end;
end.