uses crt,dos;
 var
 fi1,fi2      :text;
 st,ll        :string;
 le,chk,count :integer;
 file1,file2  :string;
 ch           :char;
 nowy         :integer;

function stp(st:string;le:integer):string;
 begin
  while length(st)<le do   st:=st+' ';
  st:=copy(st,1,le);
  stp:=st;
 end;

begin
 clrscr;
 count:=0;
 file1:=paramstr(1);
 file2:=paramstr(2);
 ll:=paramstr(3);
  if (ll='') or (file1=file2) then
    begin
      writeln('Usage> FILL sourcefile targetfile  count');
      halt;
    end  else  val(ll,le,chk);
 assign(fi1,file1);
 {$i-}reset(fi1);{$i+}
 if ioresult<>0 then
   begin
    writeln('Sourcefile not found');
    halt;
   end;
 assign(fi2,file2);
 rewrite(fi2);
 writeln('Source file:',file1);
 writeln('Target file:',file2);
 writeln('Char Length:',le);
 writeln;
 write  ('Process    :',count:5);
 nowy:=wherey;
 repeat
  count:=count+1;
  gotoxy(13,nowy);write(count:5);
  readln(fi1,st);
      gotoxy(1,15);
      writeln('':70);
      writeln('':70);
 {$i-} writeln(fi2,stp(st,le));{$i+}
 while ioresult<>0 do
    begin
      gotoxy(1,15);
      writeln(^G'Print is ready...');
      write  ('Continue ?[Y/n] ');
      ch:=readkey;
      ch:=upcase(ch);
      if ch='N' then exit;
      {$i-} writeln(fi2,stp(st,le));{$i+}
    end;
 until eof(fi1);
 close(fi1);close(fi2);
 writeln;
 writeln('end.')
end.
