繁体   English   中英

Delphi错误E2010不兼容的类型:“字符串”和“过程,无类型的指针或无类型的参数”

[英]Delphi Error E2010 Incompatible types: 'string' and 'procedure, untyped pointer or untyped parameter'

我用了TStringList和类似的东西:

geo: TStringList;
response: TStringStream;
  begin
  http:=tidhttp.Create(nil);
  try
    { TODO -oUser -cConsole Main : Insert code here }
    geo:=TStringList.Create;
    response:=TStringStream.Create('');
    geo.Add('name=stas');
    geo.Add('pass=431');
    s:=http.Get('http://test.me');
    writeln(http.ResponseText);
    writeln(s);
    s:=http.Post('http://test.me',geo,response);

但是出事了 例如,当我运行它它与错误警报[[DCC Error] consoleHttp.dpr(29): E2010 Incompatible types: 'string' and 'procedure, untyped pointer or untyped parameter']s:=http.Post('http://test.me',geo,response) 我做错了什么?

此错误意味着您将错误的参数传递给方法TIdHTTP.post 此方法有几个重载

function Post(AURL: string; ASource: TIdStrings): string; overload;
function Post(AURL: string; ASource: TIdStream): string; overload;
function Post(AURL: string; ASource: TIdMultiPartFormDataStream): string; overload;
procedure Post(AURL: string; ASource: TIdMultiPartFormDataStream; AResponseContent: TIdStream); overload;
procedure Post(AURL: string; ASource: TIdStrings; AResponseContent: TIdStream); overload;
procedure Post(AURL: string; ASource, AResponseContent: TIdStream); overload;

但没有一个与您要传递的参数匹配。

做这个:

http.Post('http://test.me',geo,response);

代替:

s:=http.Post('http://test.me',geo,response);

唯一的匹配方法是过程,但是过程不返回值。 该错误信息表明您无法将过程分配给字符串。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM