Ver Mensaje Individual
  #4  
Antiguo 24-02-2012
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola Paulao.

A ver si interpreté bién lo que estas buscando...
Código Delphi [-]
function TextFoundInFile(Ruta: string; const Buscado: string): TStrings;
var
  SR: TSearchRec;
  txt: TextFile;
  Row: string;
  Found: Boolean;
begin
  Result:= TStringList.Create;
  Ruta:= IncludeTrailingPathDelimiter(Ruta);
  if FindFirst(Ruta + '*.PAS', $FF, SR) = 0 then
    repeat
      AssignFile(txt,Ruta + SR.Name);
      Reset(txt);
      Found:= False;
      while not Eof(txt) and not Found do
      begin
        Readln(txt, Row);
        if Pos(Buscado, Row) > 0 then
        begin
          Result.Add(Ruta + SR.Name);
          Found:= True;
        end;
      end;
      CloseFile(txt);
    until FindNext(SR) <> 0;
end;

Llamada de ejemplo:
Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
begin
  ListBox1.Items:= TextFoundInFile(edRuta.Text, edBuscado.Text);
  TextFoundInFile(edRuta.Text, edBuscado.Text).SaveToFile('C:\LISTA.TXT')
end;

Saludos.
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....

Última edición por ecfisa fecha: 24-02-2012 a las 17:30:14.
Responder Con Cita