Next: , Previous: not, Up: Reference



Null

Synopsis

     var
       Null: Void absolute 0;

Description

Null is a predefined variable at address nil. Null can be passed as a “void” argument to a procedure, function or operator expecting a “var” parameter. Note: Make sure they can handle this case, otherwise this is likely to cause an exception and the program will be terminated. Since Null is an L-value, it can be taken as “nil-reference”.

Conforming to

Null is a Borland Delphi extension.

Example

     program NullDemo;
     type
       PString = ^String;
     var
       Com1: String (25) = 'This is an amazing number';
       Com2: String (25) = 'This is a boring number';
     
     procedure FooBar (Foo: Integer; var Comment: PString);
     begin
       if Odd (Foo) then
         WriteLn ('FooBar:', Foo, ' is odd')
        else
         WriteLn ('FooBar:', Foo, ' is even');
       if @Comment <> nil then
         if not Odd (Foo) then
           Comment := @Com1
         else
           Comment := @Com2
     end;
     
     var
       S: String (25);
       P: PString value @S;
     
     begin
       { FooBar allows you to leave out variables
         for any information you might not need }
       FooBar (1, Null);
       { But FooBar is flexible, after all }
       FooBar (6, P);
       WriteLn ('FooBar said about 6: `', P^, '''')
     end.

See also

nil