Robert Meek wrote:
> You confirmed what I thought.  From what I've been able to find out,
> there are three ways to end the life of a dynamic array.  The first is to
> delete it's last element, ( I was calling them fields before...sorry ), in
> which case Delphi will dispose of it because it's reference count goes to
> zero.  The second, by setting it to nil.  And the third by setlength(array,
> 0).

What's the difference between deleting the last element and setting the 
length to zero?

> I knew that an Array isn't a TComponent descendant but what struck
> me as strange is that CodeInsight shows I can do this:
> MyArrayofTComponents[0].Create()

That's taking the first element of the array, which is a value of type 
TComponent, and calling the Create method on that component.

MyArrayOfTComponents is an array. MyArrayOfTComponents[0] is a 
TComponent reference within that array.

> and asks for an Owner where the Array is
> one of a set of TComponent.  What is it attempting to create here?  I
> thought perhaps it was a shortcut to creating an element of the type but
> though it compiles fine I get an AV as soon as I attempt to access one of
> the element properties!

You get an exception for the same reason you'd get an exception here:

var
   x: TComponent;
begin
   x.Create(nil);
end;

-- 
Rob
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to