Description |
The Pointer type provides a general use pointer to any memory based variable. That is, one that is accessed by reference.
Objects, AnsiStrings, and arrays are examples of reference based variables.
But be warned : untyped pointers are dangerous - it is normally always better to use a specific pointer reference to the data type you are using. Only then can you act up on the pointer, as in the example.
|
|
Related commands |
|
|
|
|
Example code : Referring to the current form using a Pointer variable |
var generalPtr : Pointer; // A pointer to anything formPtr : ^TForm; // A pointer to a form object
begin // The current unit's form is addressable via the self keyword
generalPtr := Addr(self);
// We can assign this pointer to the form pointer
formPtr := generalPtr;
// And set the form caption to show this
formPtr.Caption := 'Test program';
end;
|
Show full unit code |
The form is shown with caption:
Test program
|
|