Type TAnObject = Object
AField : Longint; Procedure AMethod; end; Var AnObject : TAnObject; |
then the following would be a valid assignment:
AnObject.AField := 0;
|
Inside methods, elds can be accessed using the short identi er:
Procedure TAnObject.AMethod;
begin ... AField := 0; ... end; |
Or, one can use the self identi er. The self identi er refers to the current instance of the object:
Procedure TAnObject.AMethod;
begin ... Self.AField := 0; ... end; |
One cannot access elds that are in a private section of an object from outside the objects' methods. If this is attempted anyway, the compiler will complain about an unknown identi er. It is also possible to use the with statement with an object instance:
With AnObject do
begin Afield := 12; AMethod; end; |
In this example, between the begin and end, it is as if AnObject was prepended to the Afield and Amethod identi ers. More about this in section 9.2.7, page 333