---
url: >-
  /statelake/scripting-reference/functions-and-procedures/variant-functions/varisnull.md
---

# VarIsNull

**VarIsNull** returns the boolean value of **True** if the **variant** variable or field **V** is null.

Null is still assigned, therefore this is different to an unassigned **variant** that is tested with the **VarIsEmpty** function [VarIsEmpty](/statelake/scripting-reference/functions-and-procedures/variant-functions/varisempty).

**Variant** fields from **Data Definitions** will be initialised to null, and therefore you should use this function to test them.

**Declaration**: Function VarIsNull(const V : Variant) : Boolean;

An example of its use in mapping follows.

```pascal
procedure OnMapEvent(var Value:Variant);
begin
  Value := VarIsNull(Field.Value)
end;
```

Other examples follow.

```pascal
procedure ScriptEvent (var Value : variant);
var
  bVar : variant;
  ConfYN : boolean;
begin
  LogInfo('');
  ConfYN := VarIsNull(bVar);           //bVar is uninitialised so return is FALSE
 If ConfYN = True then
    LogInfo('The variant variable aVar is NULL')
 else
    LogInfo('The variant variable aVar is not NULL');
  LogInfo('');

  bVar := 'Hello campers!'
  ConfYN := VarIsNull(bVar);           //bVar is now initialised so return is FALSE
 If ConfYN = True then
    LogInfo('The variant variable aVar is still NULL')
 else
    LogInfo('The variant variable aVar is still not NULL');
  LogInfo('');

  bVar := null;                        //bVar is now NULL so return is TRUE
  ConfYN := VarIsNull(aVar);
 If ConfYN = True then
    LogInfo('The variant variable aVar is now NULL')
 else
    LogInfo('The variant variable aVar anything other than NULL');
  LogInfo('');

end;
```
