Im trying to process a plain text file (loaded into a StringList), by using class Tbb2uc but getting AV at calling function GetAddress.
TArrayQuotePositions =
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.
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.