Sign in Join
FPDoc Onlineexperiment

Fail procedure

In unit System

Fail a constructor.

Declaration

pascal
procedure Fail

Description

Fail can be used in a constructor for an object or class. It will exit the constructor at once, and the memory allocated for the constructor is freed. This mean that for objects allocated with New, the resulting pointer is Nil and for classes, the object instance will be Nil.

See also

Example: ex116.pp

pascal
program testfail;

{$mode objfpc}

Type
  TMyClass = Class
    Constructor Create;
  end;
  
  
Constructor TMyClass.Create;    

begin
  Fail;
end;

var
  M : TMyClass;
  
begin
  M:=TMyClass.Create;
  Writeln('M is nil : ',Not Assigned(M));
end.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.