procedure inport_text;
const prgid='.7ba';
var    h,a,b,n,code,count:integer;
       st,s1,s2,s3,s4:string;
       chr1:char;
       auto,new,ontext:boolean;
       config:text;

begin
  load_conf(prgid);
  new:=false;
  count:=1;
  n:=80;
  if paramcount=0 then begin {menu ins}
    repeat
      code:=3;
      case count of
	1:  repeat
	       menu(1,'Programma di composizione file di email');
	       centre(3,'Questo programma estrae gli indirizzi e-mail da un file testo singolo');
	       centre(4,'e li agginge nel database od in un altro archivio testo');
	       input_name(10,10,1,'File sorgente?',st_name2,code);
		if present(st_name2) and (code<>3) then begin
		 assign(config,st_name2);
		 reset(config);
		 clrscr;
		 for n:=1 to 20 do
		   if not(eof(config)) then begin
		     readln(config,st);
		     writeln(copy(st,1,79));
		   end;
		 writeln;
		 close(config);
		 chr1:='s';
		 get_chr(1,24,'E` questo il file sorgente?',chr1);
	       end;
	     until (chr1 in ['s','S']) or (code=3);
      2:repeat
	  if st_name='' then
	    st_name:=st_name2;
	  clrscr;
	  input_name(10,12,0,'File destinazione?',st_name,code);
	  new:=false;
	  if present(st_name) then begin
	    get_boo(10,13,'Il file esiste; cancello il precedente?',new);
	  end;
	  if st_name=st_name2 then
	    message('Nome Files sorg. e dest. non possono essere uguali',1,1);
	 until (st_name2<>st_name) or (code=3);
      3: begin
	   code:=0;
	   ontext:=false;
	   get_boo(10,14,'Vuoi creare un file testo?',ontext);

	 end;

    end;
    if code=0 then
      inc(count)
    else
      dec(count);
  until not(ranged(count,1,3));
  if code=0 then
    fromfile(st_name2,st_name,not(ontext),new,ontext,false);
  end
  else begin { linea comandi}
    code:=0;
    st_name:=paramstr(1);
    st_name2:=paramstr(2);
    case paramcount of
       1,2:fromfile(st_name2,st_name,true,false,false,new);
       3:begin
	   n:=int_val(paramstr(3));
	   fromfile(st_name,st_name2,true,false,true,new);
	 end;
       1,2,4:writeln(' Parametri insufficienti o di troppo');
       5,6:begin
	  n:=int_val(paramstr(3));
	  a:=int_val(paramstr(4));
	  b:=int_val(paramstr(5));
	  if (paramcount=6) and (paramstr(6)='/a') then
	    auto:=true
	  else auto:=false;
	  h:=0;
	  for code:=1 to length(st_name) do
	    if st_name[code]='?' then inc(h); {cerca num.car da sost.}
	  if h>0 then begin
	    s1:=copy(st_name,1,pos('?',st_name)-1);  {copie per elab.}
	    s2:=copy(st_name,pos('?',st_name)+h,255);
	    s3:=copy(st_name2,1,pos('?',st_name2)-1);
	    s4:=copy(st_name2,pos('?',st_name2)+h,255);
	    for count:=a to b do begin
	      st_name:=s1+stst2(count,h,0)+s2;
	      st_name2:=s3+stst2(count,h,0)+s4;
	      chr1:='S';
	      if not auto then
		get_Chr(10,10,'Procedo con files "'+st_name+'" e "'+st_name2+'" ?',chr1);
	      if upcase(chr1)='S' then
		fromfile(st_name2,st_name,true,false,true,new);
	     end;
	  end
	  else message2('errore nel parametri 1 o 2 ,mancano i car. ??',1,1);
	 end;
    else message2('Parametri incongruenti',1,1);
  end;

  end;
  save_conf(prgid);
end;