I don’t seem to have FreeThenNil  I’m using FPC 3.0.4RC1 I don’t use Lazarus.. 
maybe it’s a Lazarus thing… or maybe it’s in a different unit 

 

plotdraw.pax.pas(20,7) Error: Identifier not found "FreeThenNil"              

 

James

 

From: fpc-pascal <fpc-pascal-boun...@lists.freepascal.org> On Behalf Of 
Giuliano Colla
Sent: Monday, May 20, 2019 6:01 PM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] Checking if a TStringList already exists

 

Il 20/05/2019 15:23, James Richters ha scritto:

Thank you very much for the explanation and examples of this!   I am glad you 
pointed out the FreeAndNill() function, I will defiantly be needing that.
 
James


Then you might also appreciate the function Assigned. Assigned(P) returns true 
if P is non-nil, and false if P is Nil. Nothing fancy, just making the code 
more readable.

>From fpc documentation:



Program Example96;
 
{ Program to demonstrate the Assigned function. }
 
Var P : Pointer;
 
begin
  If Not Assigned(P) then
    Writeln ('Pointer is initially NIL');
  P:=@P;
  If Not Assigned(P) then
    Writeln('Internal inconsistency')
  else
    Writeln('All is well in FPC')
end.

Giuliano

P.S. In some rare case when dealing with complex objects you might need 
FreeThenNil() in place of FreeAndNil(). Give a look to 
https://lists.lazarus-ide.org/pipermail/lazarus/2011-April/062743.html



-- 
Do not do to others as you would have them do to you.They might have different 
tastes.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to