VarIsEmpty
function VarIsEmpty(const V: Variant): Boolean;
Example
procedure ScriptEvent(var Value: variant);
var
Candidate: Variant;
begin
Candidate := Unassigned;
Value := VarIsEmpty(Candidate); // True
end;
Usage
VarIsEmpty tests whether a Variant contains exactly the Empty or Unassigned state.
Parameters and result
| Item | Type | Description |
|---|---|---|
V | Variant (const) | Value to inspect. Velox resolves nested Variant/by-reference Variant indirection for the predicate. |
| Result | Boolean | True only when the resolved stored type is varEmpty; otherwise False. |
Additional Technical Info
VarIsEmpty returns True only when V contains the Variant Empty state represented by varEmpty and normally produced by Unassigned or an uninitialised Variant.
The example is fictional and source-reviewed only.
Implementation and behaviour
The modified PascalScript runtime registers System.Variants.VarIsEmpty directly. Delphi resolves the underlying Variant data and compares its type code with varEmpty; it does not convert or compare the value.
Consequently:
Nullis not Empty;'', zero andFalseare not Empty;- a nil interface Variant is not Empty, even though
VarIsClearcan regard it as clear; - an allocated array with no meaningful business values is still not Empty; and
- a custom Variant's clear semantics are not consulted.
Use this predicate when the distinction between never-assigned and explicitly missing/Null is meaningful. Do not use it as a general blank-value test.
Side effects, errors, performance and concurrency
The routine performs a type inspection only. It has no side effects, I/O, allocation or locale dependency and is constant-time apart from following Variant indirection. Normal built-in values do not raise. Concurrent access is safe only while the same underlying Variant is not being changed by another execution context.
Related entries
VarIsClearalso recognises nil interfaces and custom clear values.VarIsNullrecognises the explicit Null state.VarTypereturns the actual type code rather than a Boolean classification.
External references
- Embarcadero DocWiki:
System.Variants.VarIsEmpty - Free Pascal:
Variants.VarIsEmpty- compatibility context for Empty/Unassigned testing.