Expression illegal in evaluator (& Access Violation)

前端 未结 2 375
情话喂你
情话喂你 2021-01-29 13:25

Im trying to process a plain text file (loaded into a StringList), by using class Tbb2uc but getting AV at calling function GetAddress.

  TArrayQuotePositions =          


        
相关标签:
2条回答
  • 2021-01-29 13:43

    It was a static array that i was over-indexing. The debugger cannot pinpoint the exact line so it was not obvious (for me):

    function Tbb2uc.GetQuotePositions( aLine: string ): TArrayQuotePositions;
    var
      i: integer;
      arraypos: integer;
    begin
      for i := low(TArrayQuotePositions) to high(TArrayQuotePositions) do begin
        Farrayquotes[i] := 0;
      end;
      arraypos := low(TArrayQuotePositions);
      for i := 1 to length(aLine) do begin
        if aLine[i] = CHAR_FOR_COLLECT then begin         
          Farrayquotes[arraypos] := i;  //over-indexing, Farrayquotes: TArrayQuotePositions = array[1..4] of integer;
          inc(arraypos);            
        end;
      end;
      result := Farrayquotes;
    end;
    

    Sorry... indeed my question was far from complete.

    0 讨论(0)
  • 2021-01-29 13:45

    You are accessing your stringlist out of bounds.

    for i := 0 to SlInput.Count -1 do begin
    
     // ...(etc)
    
          addr := GetAddress(SlInput[i+2]); 
    

    i is running to the full size of the list. You are indexing two higher than that.

    0 讨论(0)
提交回复
热议问题