Name

Absolute Directive

Syntax

var Declaration absolute Constant expression;
var Declaration absolute Variable;

Description

The absolute directive tells Delphi to store a variable at a particular memory address. The address can be a numerical address or it can be the name of a variable, in which case the memory location is the same as that used for the Variable. You can use the absolute directive with local or global variables.

Tips and Tricks

  • Don’t use the absolute directive unless you absolutely have to. Instead, you should usually use variant records, which are less error-prone and easier to read and understand.

  • Use absolute instead of variant records when you cannot reasonably change the variable’s type. For example, a subroutine that must reinterpret its argument might use absolute.

  • Using absolute with a numerical memory address is a holdover from Delphi 1 and has no real use in the newer 32-bit Windows operating systems.

Example

See the Extended type for an example of using absolute.

See Also

Record Keyword, Var Keyword

Get Delphi in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.