Pedron,
Cita:
Empezado por Pedron
...como hacer para mostrar el numero del renglón donde esta una palabra...que imprima esto en un .txt...
|
Revisa este código:
Código Delphi
[-]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, StrUtils;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i, p : Integer;
Msg : String;
SL : TStringList;
Search : Boolean;
begin
SL := TStringList.Create;
for i := 0 to Memo1.Lines.Count - 1 do
begin
Search := True;
p := 0;
while Search do
begin
p := PosEx(Edit1.Text, Memo1.Lines.Strings[i],p);
if (p <> 0) then
begin
Msg := Format('Literal %s Encontrado en la Línea Número %d Posición %d',
[Edit1.Text,i,p]);
MessageDlg(Msg,mtInformation,[mbOK],0);
SL.Add(Msg);
p := p + Length(Edit1.Text);
end
else
Search := False;
end;
end;
SL.SaveToFile('SearchWord.txt');
SL.Free;
end;
end.
El código anterior en Delphi 7 bajo Windows 7 Professional x32,
busca un literal en un TMemo y por cada ocurrencia muestra y salva en un archivo txt la línea y posición del literal encontrado.
Espero sea útil
Nelson.