SystemAssigned (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example demonstrates that the System Assigned function succeeds.

Code

procedure TForm1.Button1Click(Sender: TObject);
var P: Pointer;
begin
  P := nil;
  if Assigned (P) then
    MessageDlg('You won''t see this', mtInformation, [mbOK], 0);
  GetMem(P, 1024);	{P valid}
  FreeMem(P, 1024);	{P no longer valid and still not nil}
  if Assigned (P) then
    MessageDlg('You''ll see this', mtInformation, [mbOK], 0);
end;

Uses