{ Programm Split }
{$I+}
uses dos;

const bufsize            =1024;
      splitsize          =355000;
      count     :longint =0;
      extcount  :word    =0;

var   buffer             :array[1..bufsize] of byte;
      d                  :dirstr;
      e,ex               :extstr;
      infile,outfile     :file;
      fsize              :longint;
      n                  :namestr;
      batfile            :text;
      result             :word;

{***************************************************************************}

begin
 if paramcount=0 then
    begin
     writeln('Usage :  SPLIT <file to split> ');
     halt;
    end;

 assign(infile, paramstr(1) );
 reset(infile, 1);
 fsize :=filesize(infile);
 fsplit(paramstr(1),d,n,ex);
 assign(batfile,d+'CREATE.BAT');
 rewrite(batfile);

 repeat
  inc(extcount);
  str(extcount,e);
  if extcount >1 then
     begin
      writeln(batfile, 'COPY /B ',n,'.1',' + ',n,'.',e);
      writeln(batfile, 'DEL ',n,'.',e);
     end;
  assign(outfile,d+n+'.'+e);
  rewrite(outfile,1);

  repeat
   blockread(infile,buffer,bufsize,result);
   blockwrite(outfile,buffer,result);
   inc(count,result);
  until (count=fsize) or (count >=extcount*splitsize) or (result<>bufsize);

  close(outfile);

 until count=fsize;

 close(infile);
 writeln(batfile,'REN ',n,'.1',n,ex);
 close(batfile);

end.