SmartPascal
Addr
Function
Gives the address of a variable, function or procedure System unit
1  function Addr ( Variable name ) : Pointer;
2  function Addr ( Function name ) : Pointer;
3  function Addr ( Procedure name ) : Pointer;
Description
The Addr function returns the address of a Variable, Function or Procedure.
 
It is similar to the @ operator, but is not constrained by the $TypedAddress compiler directive - it always returns an untyped Pointer.
 
You can cast this to a typed pointer, as in the example.
Related commands
Pointer Defines a general use Pointer to any memory based data
 
Example code : Using the address of a string to display the string
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.
 
unit Unit1;
 
interface
 
uses
  // The System unit does not need to be defined
  Forms, Dialogs;
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;
 
var
  
Form1: TForm1;
 
implementation
{$R *.dfm} // Include form definitions
 
procedure TForm1.FormCreate(Sender: TObject);

var
  myString  : string;
  ptrString : PString;
begin
  // Set up variable values
  myString := 'Hello there';

  ptrString := Addr(myString);
  ShowMessage('myString : '+ptrString^);
end;
 
end.
Hide full unit code
   myString : Hello there