I think what you've got is a dynamic array. So you need to call 
SetLength(array,length) to initialise the array. You can avoid this by using a static 
array (one declared with [1..100]).

The advantage of a static array is that it can be re-sized by another call to 
SetLength(array,length).

Also, the array is of object references. So if you want to create a new object in the 
array you need to do it like:

Array[x] := TMyObject.Create;

I think that is what you are trying to do. This will create a new object and reference 
it from Array[x]. To free it you go

Array[x].Free;

-----Original Message-----
From: Alistair George [mailto:[EMAIL PROTECTED]
Sent: Monday, 31 March 2003 10:50 a.m.
To: Multiple recipients of list delphi
Subject: [DUG]: Array of components


Hi All having probs creating an array (in Create line):

  DirMonArray: array of TDirMonitor;  //can this be an open array - or must it
have [0..100] for example assigned?

procedure TMainform.DirMonArrayAdd(WatchDir: string);
var Tval: Integer;
  CurrDir: string;
begin
//Irrelevant lines removed
  inc(DmonCount, 1);
  DirMonArray[DmonCount - 1].Create(self);  //<<= creation error here
end;




Help??

---------------------------------------------------------------------------
    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"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
---------------------------------------------------------------------------
    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"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to