Hi Ross,
You have to allocate the size of the array before you start storing things.
For a dynamic array, as you've declared in your example, use the SetLength()
procedure (declared in System.pas).
eg
var
Categories : array of TStringList;
begin
SetLength(Categories, <any expression, variable or constant of integer
type>);
Categories[0] := TStringList.Create;
...
// When you're done, free the stringlists
...
// and then release the memory allocated for the dynamic array
Categories := nil;
end;
You can also truncate a dynamic array using Copy()
Paul.
At 19:55 5/07/01 , you wrote:
>I was hoping the following would work but it appears not. It compiles
>OK but produces memory errors at runtime. Why doesn't the compiler
>complain if TSringList can't be used in an array?
>
>var
> Categories : array of TStringList;
>begin
> Categories[0] := TStringList.Create;
>end;
>
>Cheers,
>Ross.
>
-------------------------------------------------------------
Paul Spain, Excellent Programming Company
mailto:[EMAIL PROTECTED]
-------------------------------------------------------------
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"