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;
我在以下函數中收到上述錯誤。我怎樣才能解決這個問題?代碼是由另一個編碼器給我的,但我是一個完整的業餘愛好者,所以我將不勝感激!E2251對'Pos'System.pas的歧義性重載調用(28005)
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;
此外,如果可能的話。有人能解釋一下這段代碼究竟做了什麼? – user1365875 2013-04-08 11:47:56
看起來像一個未完成的PHP像'explode'函數給我:http://www.php.net/manual/en/function.explode.php – 2013-04-08 12:08:28
你想用這個函數完成什麼? – 2013-04-08 12:09:14