[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'System' (#rtl)

Fail

Fail a constructor

Declaration

Source position: system.fpd line 94

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

TypeOf

  

Return pointer to VMT of an object

New

  

Dynamically allocate memory for variable

Initialize

  

Initialize memory block using RTTI

Finalize

  

Finalize (clean up) memory block using RTTI

Example

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.  

Documentation generated on: May 14 2021