2
    [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;
4

1 回答 1

9

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

Index := Pos(WideString(AChar + AChar), Result);
于 2013-04-08T11:34:39.747 回答