There is no overloaded version of "SendMsg" that can be called with these arguments
I am upgrading a project from Delphi 2006 to Delphi XE2 and encountered a compilation error There is no overloaded version of "SendMsg" that can be called with these arguments. This is the code where the problem is.
procedure TMessageComms.UpgradeError(Msg: String);
begin
FConnection.SendMsg(cUpgradeError, Msg, FConnection.GetNextMsgID);
end;
The SendMsg method looks like this.
procedure SendMsg(ACommand, AParamStr : String; AMsgID : Integer); overload;
procedure TMsgConnection.SendMsg(ACommand, AParamStr: String; AMsgID: Integer);
begin
// construct message
// send message
end;
cUpgradeError is const declared this way.
cUpgradeError = 'UpgradeError';
And this is the GetNextMsgID function that returns Integer.
function TMsgConnection.GetNextMsgID: Integer;
begin
Inc(FLastMsgID);
Result := FLastMsgID;
end;
All parameters seem valid to me. I was able to narrow it down to the point that it has to do with the GetNextMsgID function, but not sure what. If I pass the value returned from the function to Integer, then it compiles fine, but I don't understand why I need it.
source to share
I'm guessing I'm FConnection.SendMsg(cUpgradeError, Msg, FConnection.GetNextMsgID);
trying to interpret FConnection.GetNextMsgID
as a function pointer instead of a function result.
Change it to FConnection.SendMsg(cUpgradeError, Msg, FConnection.GetNextMsgID());
so that it understands that you are looking for the result of a function.
source to share