unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP, StdCtrls;type
TForm1 = class(TForm)
IdHTTP1: TIdHTTP;
Button1: TButton;
Memo1: TMemo;
function GetVersionInfo(MyURL: string): string;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
function GetVersionInfo(MyURL: string): string;
var
MyIdHTTPVer: TIdHTTP;
Str: string;
begin
try
try
MyIdHTTPVer := TIdHTTP.Create(self);
Str := MyIdHTTPVer.Get(MyURL);
result := Str;
except end;
finally
MyIdHTTPVer.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
memo1.Text:= GetVersionInfo('www.baidu.com');
end;end.编译后:
[Error] Unit1.pas(36): Undeclared identifier: 'self'
[Error] Unit1.pas(15): Unsatisfied forward or external declaration: 'TForm1.GetVersionInfo'
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP, StdCtrls;type
TForm1 = class(TForm)
IdHTTP1: TIdHTTP;
Button1: TButton;
Memo1: TMemo;
function GetVersionInfo(MyURL: string): string;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
function GetVersionInfo(MyURL: string): string;
var
MyIdHTTPVer: TIdHTTP;
Str: string;
begin
try
try
MyIdHTTPVer := TIdHTTP.Create(self);
Str := MyIdHTTPVer.Get(MyURL);
result := Str;
except end;
finally
MyIdHTTPVer.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
memo1.Text:= GetVersionInfo('www.baidu.com');
end;end.编译后:
[Error] Unit1.pas(36): Undeclared identifier: 'self'
[Error] Unit1.pas(15): Unsatisfied forward or external declaration: 'TForm1.GetVersionInfo'
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
function TForm1.GetVersionInfo(MyURL: string): string;
//少了 “TForm1.”
~~~~~~~
var
MyIdHTTPVer: TIdHTTP;
Str: string;
begin
.....
~~~~~~~
var
MyIdHTTPVer: TIdHTTP;
Str: string;
begin
.....
你可以用ctrl+shift+c来实现
点击那个complete.....什么的就可以完成类名的添加,,,,,
~~~~~~~
var
MyIdHTTPVer: TIdHTTP;
Str: string;
begin
.....
应该是这里的问题吧