Stran 2 od 2

search program za .txt datoteke

Objavljeno: 01.06.2010 09:40:56
Napisal/-a mig640
Hvala za tako hiter odgovor ! :)

Zanimivo...kar preprosta uporaba memo-ta ...sicer mislim da manjka uporaba TEdita za iskano besedo ? Sicer Open in Save dela :)

Še malo moram prečesat kodo (moj poskus je bil z assign file in ReadLn ...sam nism uspel povezat vsega)

Hvala!
Takole bi to lahko izgledalo brez memo1

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
OpenDialog1: TOpenDialog;
Input1: TEdit;
Memo2: TMemo;
procedure OpenFileClick(Sender: TObject);
Procedure Obstaja(s:String);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.OpenFileClick(Sender: TObject);
Var F:TextFile;
s:String;
begin
if OpenDialog1.Execute then
begin
AssignFile(F, OpenDialog1.FileName); { }
Reset(F);
while not Eof(F) do
begin
Readln(F,S);
Obstaja(S);
end;
end;
end;
Procedure TForm1.Obstaja(s:String);
begin
if Pos(Input1.Text, S) > 0
then
Memo2.Lines.Add(S);

end;
end.