Z
zx
Unregistered / Unconfirmed
GUEST, unregistred user!
我有一个程序,关于在文本中检索字符串,能帮我查错吗?
分不多了!帮帮忙!!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
procedure cutstring(position:integer
cutstring:string);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
tempfile:textfile;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
assignfile(tempfile,'d:/1/default.htm');
reset(tempfile);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
tempstring1,tempstring2:string;
imgstring,hrefstring:string;
begin
tempstring1:='';tempstring2:='';
imgstring:='img src=';
hrefstring:='a href'
while not eof(tempfile) do begin
readln(tempfile,tempstring1);
tempstring1:=lowercase(tempstring1);
if ansipos(imgstring,tempstring1)<>0 then
cutstring(ansipos(imgstring,tempstring1),tempstring2);
Memo1.Lines.Add(tempstring2);
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
closefile(tempfile);
end;
procedure TForm1.cutstring(Position:integer
cutString:string);
var
endstring:string;
i,j:integer;
begin
j:=0;i:=position;endstring:='';setlength(endstring,256);
repeat
endstring[j]:=cutstring;
i:=i+1;j:=j+1;
until (cutstring='>')and(cutstring[i+1]=' ')
cutstring:=endstring;
end;
end.
分不多了!帮帮忙!!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
procedure cutstring(position:integer
cutstring:string);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
tempfile:textfile;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
assignfile(tempfile,'d:/1/default.htm');
reset(tempfile);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
tempstring1,tempstring2:string;
imgstring,hrefstring:string;
begin
tempstring1:='';tempstring2:='';
imgstring:='img src=';
hrefstring:='a href'
while not eof(tempfile) do begin
readln(tempfile,tempstring1);
tempstring1:=lowercase(tempstring1);
if ansipos(imgstring,tempstring1)<>0 then
cutstring(ansipos(imgstring,tempstring1),tempstring2);
Memo1.Lines.Add(tempstring2);
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
closefile(tempfile);
end;
procedure TForm1.cutstring(Position:integer
cutString:string);
var
endstring:string;
i,j:integer;
begin
j:=0;i:=position;endstring:='';setlength(endstring,256);
repeat
endstring[j]:=cutstring;
i:=i+1;j:=j+1;
until (cutstring='>')and(cutstring[i+1]=' ')
cutstring:=endstring;
end;
end.