SmartPascal
Nil
Constant
A pointer value that is defined as undetermined System unit
  const Nil = Pointer(0);
Description
The Nil constant is a pointer value that is defined as undetermined.
 
Use of a Nil pointer will result in an exception.
 
Nil is mostly used as a substitute for a Pointer parameter - it tells the routine that no Pointer value is available for this parameter.
 
Pointer variables are not set to Nil except in special circumstances, such as when creating a new object that contains pointers. This is because Delphi initialises the storage taken by a new object to 0's. A Nil pointer is one that has the value 0.
Related commands
Assigned Returns true if a reference is not nil
Null A variable that has no value
Pointer Defines a general use Pointer to any memory based data
 
Example code : A simple example
var
  myPtr : PChar;

begin
  // Pointer variables are not set to nil by default
  if myPtr = Nil
  then ShowMessage('myPtr is nil')
  else ShowMessage('myPtr is not nil');

  // So we must set them to nil to be sure that they are undefined
  myPtr := Nil;
  if myPtr = Nil
  then ShowMessage('myPtr is nil')
  else ShowMessage('myPtr is still not nil');
end;
Show full unit code
   myPtr is not nil
   myPtr is nil