Name
Absolute Directive
Syntax
varDeclarationabsoluteConstant expression; varDeclarationabsoluteVariable;
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
absolutedirective unless you absolutely have to. Instead, you should usually use variant records, which are less error-prone and easier to read and understand.Use
absoluteinstead of variant records when you cannot reasonably change the variable’s type. For example, a subroutine that must reinterpret its argument might useabsolute.Using
absolutewith 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 |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access