Search code examples
delphidelphi-xe7dcc32

DELPHI XE7 [dcc32 Error] E2250 There is no overloaded version of 'Pos' that can be called with these arguments


DELPHI XE7 on win7 32bit code:

procedure TForm1.IdMappedPortTCP1Execute(AContext: TIdContext);
begin
if (pos('CONNECT',AContext)<>0) or (pos('GET',AContext)<>0) or (pos('POST',AContext)<>0) or   (pos('HEAD',AContext)<>0)
then
(....)
sleep(100);
end;

error:

[dcc32 Error] Unit1.pas(49): E2250 There is no overloaded version of 'Pos' that can be called with these arguments

please help me how to fix that code

thanks in advance


Solution

  • The arguments to Pos are two strings. The functions searches for the first occurrence of a substring (the first parameter) within another string (the second parameter). The function is documented here: http://docwiki.embarcadero.com/Libraries/en/System.Pos

    You are passing AContext which is of type TIdContext and that is not a string. To fix the code you need to pass the string that contains the text within which you intend to search.