Ver Mensaje Individual
  #7  
Antiguo 12-11-2006
mane mane is offline
Miembro
 
Registrado: may 2005
Posts: 30
Reputación: 0
mane Va por buen camino
No le veo problema a la estructura de tu fichero txt.

Código:
var l1,l2,l3,l4 : string;
    procedure extrae(cad:string;var t1,t2,t3,t4:string);
    var q : integer;
    begin
      t1:='';t2:='';t3:='';t4:='';
      q:=1;
      while copy(cad,q,1)<>'|' do
      begin
        t1:=t1+copy(cad,q,1);
        inc(q);
      end;
      inc(q);
      while copy(cad,q,1)<>'|' do
      begin
        t2:=t2+copy(cad,q,1);
        inc(q);
      end;
      while copy(cad,q,1)<>'|' do
      begin
        t3:=t3+copy(cad,q,1);
        inc(q);
      end;
      inc(q);
      t4:=copy(cad,q,3);  // el resto
    end;
 
 assignfile(ft,DirectoryEdit1.text+'\Anotacion.txt');
  {$I-}
    Reset(Ft);
  {$I+}
  if IOResult <> 0 then
  begin
    Showmessage('No se encuentra el fichero de anotaciones.');
    Exit;
  end;
  while not eof(ft) do
  begin
    Readln(ft,lin);
    extrae(lin,l1,l2,l3,l4);
    Table1.Append;
    Table1.Fieldbyname('Codigo').asinteger:=strtoint(l1);
    Table1.Fieldbyname('Numero').asstring:=l2;
    Table1.Fieldbyname('Nombre').asstring:=l3;
    Table1.Fieldbyname('Tipo').asstring:=l4;
    Table1.Post;
  end;
  Closefile(ft);
Responder Con Cita