Delphi E2267先前的'声明;提取代币';未标记为';超载';指示

Delphi E2267先前的'声明;提取代币';未标记为';超载';指示,delphi,Delphi,我不明白如何修复这个错误!!! 下面是代码中出现错误的部分。 我想不出在哪里使用过载 function ExtractTokens(const line: AnsiString; const sep: AnsiChar; autoUnquote: boolean = true): TStringArray; var lineIndex: integer; function NextChar(out ch: char): boolean; begin if lineInde

我不明白如何修复这个错误!!! 下面是代码中出现错误的部分。 我想不出在哪里使用过载

 function ExtractTokens(const line: AnsiString; const sep: AnsiChar; autoUnquote: boolean = true): TStringArray;
var
  lineIndex: integer;

  function NextChar(out ch: char): boolean;
  begin
    if lineIndex <= length(line) then
    begin
      result := true;
      ch := line[lineIndex];
      inc(lineIndex);
    end
    else
      result := false;
  end;
  function PeekFor(const ch: AnsiChar): boolean;
  begin
    result := false;
    if lineIndex <= length(line) then
    begin
      if line[lineIndex] = ch then
      begin
        inc(lineIndex);
        result := true;
      end;
    end;
  end;
  function UnquoteIfNecessary(const tok: string; quoteChar: char): string;
  var
    pch: PChar;
  begin
    if autoUnquote then
    begin
      pch := pchar(tok);
      result := AnsiExtractQuotedStr(pch, quoteChar);
    end
    else
      result := tok;
  end;
var
  token: string;
  stok: string;
  ch: char;
  lastChar: char;
  strSep: char;
  inString: boolean;

  function IsSep(aChar: char): boolean;
  begin
    result := (aChar = sep) or ((sep = #0) and (ord(aChar) < 33));
  end;

  procedure AddToken(var tokens: TStringArray; const tkn: string; addEmpty: boolean = true);
  var
    s: string;
  begin
    s := trim(tkn);
    if addEmpty or (s <> '') then
    begin
      SetLength(tokens, length(tokens) + 1);
      tokens[high(tokens)] := s;
    end;
    token := '';
  end;
begin
  result := nil;
  token := '';
  stok := '';
  lastChar := #0;
  strSep := #0; // for compiler
  inString := false;
  lineIndex := 1;
  while true do
  begin
    if not NextChar(ch) then
    begin
      AddToken(result, token, (lastChar <> #0) and IsSep(lastChar));
      exit;
    end;

    if ch in ['"', ''''] then
    begin
      stok := stok + ch;
      if inString then
      begin
        if ch = strSep then
        begin
          if PeekFor(strSep) then
            stok := stok + strSep
          else
          begin
            token := token + UnquoteIfNecessary(stok, strSep);
            inString := false;
            stok := '';
          end;
        end;
      end
      else
      begin
        strSep := ch;
        inString := true;
      end;
    end
    else if IsSep(ch) and not inString then
      AddToken(result, token, true)
    else
    begin
      if inString then
        stok := stok + ch
      else
        token := token + ch;
    end;
    lastChar := ch;
  end;
end;
函数提取令牌(const-line:AnsiString;const-sep:AnsiChar;autoUnquote:boolean=true):TStringArray;
变量
lineIndex:整数;
函数NextChar(out ch:char):布尔值;
开始

如果lineIndex则提示出现在错误消息中。让我们看看

E2267先前的“ExtractTokens”声明未标记“重载”指令

显然,您有一个名为
ExtractTokens
的函数的早期声明。找到它,你的解决方案就会显而易见


使用
重载标记这两个声明,或者根据您的意图删除其中一个声明。

显然您有另一个名为
提取令牌的函数,或者可能您得到了一个与实现不同的声明。是的,我有另一个函数提取令牌很多此错误消失了。但还有另一个问题:E2010不兼容的类型:“Char”和“AnsiChar”,这是一个不同的问题。在这个问题上帮不了你。@ValertonGT:你使用的是Unicode版本的Delphi,但这段代码混合了Ansi和Unicode字符/字符串。您需要重写代码以使用
string
而不是
AnsiString
,以及
Char
而不是
AnsiChar