[fpc-devel] comparing methods
Nino Luciani
nino at silvermono.co.za
Thu Sep 10 19:56:02 CEST 2009
On Thursday 10 September 2009 17:52:44 Florian Klaempfl wrote:
> Ivo Steinmann schrieb:
> > 1. Using =nil or Assigned should result in the same.
>
> Afaik not, this was one of the reasons for assigned.
>
I have always used Assigned() to test whether a pointer is 'valid' or is nil.
Thus Assiged() should return False if pointer is nil?
procedure Test;
var
myPtr : PChar;
begin
// Pointer variables are not set to nil by default
if Assigned(myPtr) then
ShowMessage('myPtr is not nil')
else
ShowMessage('myPtr is nil');
// So we must set them to nil to be sure that they are undefined
myPtr := Nil;
if Assigned(myPtr) then
ShowMessage('myPtr is still not nil')
else
ShowMessage('myPtr is nil');
end;
if you don't agree, don't blame me.
http://www.delphibasics.co.uk/RTL.asp?Name=Assigned
> _______________________________________________
> fpc-devel maillist - fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel
More information about the fpc-devel
mailing list