PDA

View Full Version : How to get current instance of class?



Darkhog
28-05-2013, 09:55 PM
Another noob question: Basically I'm looking into equivalent of 'this' Java keyword - way to get current instance of class.

SilverWarior
28-05-2013, 11:00 PM
In pascal you use self for accesing object instance to which current code belongs.

Also if you need to interact with same object several times in a row you can use:

with SomeObject do
begin
....
end;
So calling this:

with Form1 do
begin
Width := 640;
Height := 480;
Color := clWhite;
end;
is same as calling this:

Form1.Width := 640;
Form1.Height := 480;
Form1.Color := clWhite;

laggyluk
29-05-2013, 02:38 AM
'this' inside a class method is 'self'