Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Delphi E2251对'的不明确重载调用;Pos&x27;系统pas(28005)_Delphi_Pascal_Delphi Xe3 - Fatal编程技术网

Delphi E2251对'的不明确重载调用;Pos&x27;系统pas(28005)

Delphi E2251对'的不明确重载调用;Pos&x27;系统pas(28005),delphi,pascal,delphi-xe3,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

我在下面的函数中得到了上面的错误。我怎样才能解决这个问题?代码是另一个程序员给我的,但我是一个完全的业余爱好者,所以简单的答案将不胜感激

    [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;
函数ExplodeStr(const-AString:WideString;AWordIndex:Integer;AChar:Char):WideString;
变量
索引、计数器:整数;
开始
结果:=修剪(收敛);
计数器:=0;
指数:=Pos(AChar+AChar,结果);
当索引>0时,请执行以下操作:
开始
删除(结果,索引,1);
指数:=Pos(AChar+AChar,结果);
结束;
索引:=位置(AChar,结果);
而((计数器0))不
开始
删除(结果,1,索引);
索引:=位置(AChar,结果);
计数器:=计数器+1;
结束;
如果(计数器0,则
删除(结果、索引、最大值);
结束;

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

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;

还有,如果可能的话。有人能解释一下这段代码到底是做什么的吗?对我来说,它看起来像一个未完成的PHP函数,比如
explode
函数:你到底想用这个函数完成什么?感谢这个简单的修复,它开始让我发疯了:-)
Index := Pos(WideString(AChar + AChar), Result);