簡體   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