home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
MBUG
/
MBUG075.ARC
/
STRIP.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1979-12-31
|
2KB
|
71 lines
Program Strip;
{CPM version.. 13-03-87}
{ 21-03-87}
{ 23-03-87}
{ 25-03-87}
{$C-}
Const
Controls : set of char = [#0..#8,#11..#13,#14..#31,#127..#255];
Bell = #07;
Space = ' ';
{Remove all control characters except LF, HT}
{This CPM version formats ok with WordStar and Glass files by
removing CR's also.}
Var
Old,New : Text;
Ch : Char;
Oldname,Newname : String[14];
ControlFlag : Boolean;
Function Control(var ch:char) : Boolean;
begin
ch := chr(ord(ch) and $7F);
control := ch in controls;
end;
begin
write('Old name: ');
readln(oldname);
assign(old,oldname);
{$I-}
reset(old);
{$I+}
if ioresult <> 0 then
begin
writeln(bell,'ERROR.... This filename does not exist.');
writeln('Please recheck filename from directory.');
halt; {Exit to CP/M if error}
end;
write('Enter new filename: ');
readln(newname);
assign(new,newname);
rewrite(new);
ControlFlag := false;
while not eof(old) do
begin
read(old,ch);
if (ord(ch) = 16) then {Used to add a space in text when char 16 }
begin {is removed, otherwise no gap between these words}
ch := space;
end;
if (ord(ch) = 1) or (ord(ch) = 2) then
begin
controlflag := true;
end
else if ((ord(ch) = 32) or (ord(ch) = 255)) and (controlflag) then
begin
controlflag := false;
end;
if not control(ch) and not controlflag then
begin
write(ch);
write(new,ch);
end;
end;
close(new);
close(old);
end.