E2251对“Pos”System.pas(28005)的过度调用

时间:2013-04-08 11:23:19

标签: delphi pascal delphi-xe3

    [dcc32 Error] psystr.pas(249): E2251 Ambiguous overloaded call to 'Pos'
    System.pas(28005): Related method: function Pos(const string; const string; Integer):         Integer;
    System.pas(28165): Related method: function Pos(const WideString; const WideString;     Integer): Integer;

我在以下功能上遇到上述错误。我怎样才能解决这个问题?代码是由另一个程序员给我的,但我是一个完全的业余,所以简单的答案将不胜感激!

function ExplodeStr(const AString: WideString; AWordIndex: Integer; AChar: Char): WideString;
var
  Index, Counter: Integer;
begin
  Result  := Trim(AString);
  Counter := 0;
  Index   := Pos(AChar + AChar, Result);
  while Index > 0 do
  begin
    Delete(Result, Index, 1);
    Index := Pos(AChar + AChar, Result);
  end;
  Index := Pos(AChar, Result);
  while ((Counter < AWordIndex) and (Index > 0)) do
  begin
    Delete(Result, 1, Index);
    Index := Pos(AChar, Result);

    Counter := Counter + 1;
  end;
  if (Counter < AWordIndex) then
    Result := '';
  Index    := Pos(AChar, Result);
  if Index > 0 then
    Delete(Result, Index, MaxInt);
end;

1 个答案:

答案 0 :(得分:9)

在系统中有超载的POS版本,你只需告诉编译器他必须使用哪一个,例如通过调用

Index := Pos(WideString(AChar + AChar), Result);