Ver Mensaje Individual
  #3  
Antiguo 09-06-2008
Avatar de Caro
*Caro* Caro is offline
Moderadora
 
Registrado: jul 2004
Ubicación: Cochabamba, Bolivia
Posts: 2.544
Reputación: 22
Caro Va por buen camino
Hola Paulao, te pongo otro ejemplo.

Código Delphi [-]
function TForm1.Contenido(Linea, Cadena : String; PosInicio:Integer): String;
var
 CadRestante : String;
 PosFinal       : Integer;
 Resultado     : String;
begin
 CadRestante := Copy(Linea, PosInicio+Length(Cadena), Length(Linea));
 if CadRestante[1] =' ' then
  CadRestante := Copy(CadRestante, 2, Length(CadRestante)-1);
 PosFinal := Pos(' ', CadRestante);
 if PosFinal >0 then
  Resultado := Copy(CadRestante, 1, PosFinal-1)
 else
  Resultado := Copy(CadRestante, 1, Length(CadRestante));
 Result := Resultado;
end;
 
procedure TForm1.Button1Click(Sender: TObject);
var
 Archivo  : TextFile;
 Linea    : String;
 BandItem : Boolean;
 PosInicio, PosItem  : Integer;
 Cont : String;
begin
 AssignFile(Archivo, 'archivo.txt');
 Reset(Archivo);
 BandItem := False;
 While not Eof(Archivo) do
  begin
   Readln(Archivo, Linea);
 
   PosItem := Pos('ITEM', Linea);
   if (PosItem<>0) or (BandItem) then
    begin
     BandItem := True;
     Memo1.Lines.Add(Linea);
     if Pos('SUBTOTAL', Linea)>0 then
      BandItem := False;
    end
   else
    begin
     PosInicio := Pos('CCF:', Linea);
     if PosInicio>0 then
      begin
       showmessage(Contenido(Linea, 'CCF:',PosInicio));
       PosInicio := 0;
      end;
     PosInicio := Pos('COO:', Linea);
     if PosInicio>0 then
      begin
       showmessage(Contenido(Linea, 'COO:',PosInicio));
       PosInicio := 0;
      end;
     PosInicio := Pos('CNPJ/CPF CONSUMIDOR:', Linea);
     if PosInicio>0 then
      begin
       showmessage(Contenido(Linea, 'CNPJ/CPF CONSUMIDOR:',PosInicio));
       PosInicio := 0;
      end;
     PosInicio := Pos('NOME:', Linea);
     if PosInicio>0 then
      begin
       showmessage(Contenido(Linea, 'NOME:',PosInicio));
       PosInicio := 0;
      end;
    end;
  end;
end;

Saluditos
__________________
Disfruten cada minuto de su vida a lado de sus seres queridos como si fuese el ultimo, uno nunca sabe lo que puede pasar.
Responder Con Cita