Assigned

From Delphi Pascal wiki
Jump to navigation Jump to search

Tests to determine if a pointer or procedural variable is nil.


Declaration
function Assigned(var P): Boolean;


Target
Windows, Real, Protected


Remarks
P must be a variable reference of a pointer or procedural type. Assigned(P) corresponds to the test P<> nil for a pointer variable, and @P <> nil for a procedural variable.


Returns
True if P is nil, false otherwise.


Sample Code

{Assigned.PAS}
{Sample code for the Assigned function. }

{ For Windows: }
{ uses WinCrt; }
var P: Pointer;
begin
 P := nil;
 if Assigned (P) then Writeln ('You wont see this');
 P := @P;
 if Assigned (P) then Writeln ('Youll see this');
end.