用于测试空(或未分配)的指针或过程变量
function Assigned(var P): Boolean;
Description
Use Assigned to determine whether the pointer or procedure referenced by P is
nil. 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.
Assigned returns False if P is nil, True otherwise.
举例如下
procedure TForm1.Button1Click(Sender :TObject);
var P: Pointer;
begin
P := nil;
if Assigned (P) then Writeln ('You won''t see this');
GetMem(P, 1024); {P valid}
FreeMem(P, 1024); {P no longer valid and still not nil}
if Assigned (P) then Writeln ('You''ll see this');
end;