unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdTCPClient;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
public
Flist : TList;
property list : TList read Flist write Flist;
end;
Tmy_class = class(TThread)
public
procedure test;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure Tmy_class.test;
begin
// Error here, can't access the Flist var or list propertie, help !! How to access?
TForm1(TList).list.Clear;
// Error
Form1.list.Clear;
// Error
Form1.Flist.clear;
// HOW ????????
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Flist := FList.Create;
end;
end.
How to get access to “Flist” variable ?
Thanks.
Delphi 2010, Indy 10, Win7
Yeap, thats freeking me out:
Your post does not have much context to explain the code sections; please explain your scenario more clearly.
You need to address the variable Form1.
But doing this from a thread is not safe.
Update : compiles fine.
But as I warned before, using List directly from a thread is not a good idea.
See also the comment how to create your list.
And yes, the TMyClass has to be properly initiated somewhere.