I am running Lazarus-0.9.29-25159 and fpc-2.4.1-20100504 for Win 64-bit on a Windows 7 (64-bit) machine. I passed a TStringList object by reference to a function that I created. The function works perfectly, but inside the function I get an Access Violation if I try to run this code:
function TImportForm.ParseStr(Line:String;Delim,Quote:Char;var Data:TStringList) : Boolean;
begin
Data.Clear; //Access violation
end;
But I don't get any errors if I run:
function TImportForm.ParseStr(Line:String;Delim,Quote:Char;var Data:TStringList) : Boolean;
begin
Data.Add('Test String');
Data.Add('Test String2');
Data.Add('Test String3');
end;
Then, after using this function (without using the Clear function) I get an Access Violation when I call:
ParseStr(CurrLine,ColumnChar,QuoteChar,Fields);
ShowMessage(Fields.Strings[1]);
What would cause an Access Violation with Clear and Strings[1], but not with Add?