|Subject:||Re: Access instance created in with .. do|
|Posted by:||Joanna Carter [TeamB] (firstname.lastname@example.org)|
|Date:||Wed, 21 Jun 2006|
"Christian Gorski" <email@example.com> a écrit dans le message de news:
| Is there any possibility to access the reference pointer to an instance
| of an object created in with .. do?
| For example, I want to call SomeFunc with the created instance of TObj:
| with TObj.Create do begin
First of all "with" is evil ! :-))
Second, if you really insist on using it, then you need to add a method,
that returns self, to the class that you are trying to use
TObj = class
function GetThis: TObj;
function TObj.GetThis: TObj
Thirdly, if you are going to call free in the with block I suggest you also
include a correctly declared try..finally block inside it.
with TObj.Create do
But better still would be to do things properly and not have to mess up your
classes for the sake of a couple of extra keypresses when typing the code.
obj := TObj.Create;
Joanna Carter [TeamB]
Consultant Software Engineer
Access instance created in with .. do posted by Christian Gorski on Wed, 21 Jun 2006