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

# VarIsEmpty

The **VarIsEmpty** function returns the boolean value of **True** if the **variant** variable or field **V** is unassigned.

This is not normally used with **Statelake** unless work is being done with locally declared variables.

**Variant** fields from **Data Definitions** will be initialised to null, and therefore can never be unassigned - therefore the **VarIsNull** function should be used to test these fields. Please refer to [VarIsNull](/statelake/scripting-reference/functions-and-procedures/variant-functions/varisnull).

The **VarIsEmpty** function is also unable to detect whether a **variant** with a **COM** reference assigned to it has been cleared. For this, please refer to the **VarIsClear** function.

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

A simple example would be as follows.

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

This can also be seen through the following code.

```pascal
procedure ScriptEvent (var Value : variant);
var
  aVar : variant;
  ConfYN : boolean;
begin
  LogInfo('');
  ConfYN := VarIsEmpty(aVar);
 If ConfYN = True then
    LogInfo('The variant variable aVar is EMPTY')
 else
    LogInfo('The variant variable aVar has been ILITIALISED');
  LogInfo('');

  aVar := 'Hello, how is the weather?';
    ConfYN := VarIsEmpty(aVar);
 If ConfYN = True then
    LogInfo('The variant variable aVar is still EMPTY')
 else
    LogInfo('The variant variable aVar has NOW been INITIALISED');
  LogInfo('');

  aVar := null;
  ConfYN := VarIsEmpty(aVar);
 If ConfYN = True then
    LogInfo('The variant variable aVar is still EMPTY - it is NULL')
 else
    LogInfo('The variant variable aVar has NOW been INITIALISED - it is NULL');
  LogInfo('');

end;
```
