Assigned Function
function Assigned(P: Pointer): Boolean; function Assigned(Obj: TObject): Boolean; function Assigned(Method: TMethod): Boolean;
The Assigned
function returns True if the argument
is not nil
; it returns False if the argument is
nil
. Assigned
is not a real
function.
The argument can be a pointer, an object reference, or a method.
Calling Assigned
instead of comparing a pointer
with nil
incurs no performance penalty.
If the pointer is a function pointer, using
Assigned
makes it clear that you do not intend to
call the function and compare its result to nil
.
Thus, Assigned
is often used to test function and
method
pointers.
A method pointer has two parts: a code pointer and a data pointer.
Assigned
checks only the most significant word of
the code reference: if the high-order word is zero, the method
reference is nil
. Assigned
ignores the data pointer.