varBoolean
varBoolean = 11
Example
function HasBooleanType(const Value: Variant): Boolean;
begin
Result := (VarType(Value) and varTypeMask) = varBoolean;
end;
Usage
varBoolean identifies a Variant Boolean stored with Velox and Automation's 16-bit WordBool representation.
Additional Technical Info
varBoolean is the base TVarType code $000B for a Variant Boolean. Delphi's underlying field is WordBool, compatible with Automation VARIANT_BOOL: false is zero and canonical true is all bits set (-1 when interpreted as signed 16-bit).
Script code should use Boolean expressions and conversions rather than reading or depending on that physical bit pattern. In particular, treating the payload as an ordinary integer 1 is not a portable representation test. VarType inspects the tag without converting the value.
Conversion behavior
- Assigning
TrueorFalseto a Variant normally creates this type. VarAsTypecan requestvarBoolean; supported source text/numbers are converted under Delphi Variant rules and invalid values can raise a conversion exception.- Boolean-to-string output is affected by Delphi's process-global Boolean conversion settings; use an explicit business format when an integration requires
Y/N,1/0or another contract. - Null and Empty require separate policy. A type-code test must not be replaced by truthiness.
The code can be combined with varArray or varByRef. Mask to test the base type, then handle the flag and lifetime separately. Inspection is constant-time and performs no I/O; conversion can allocate or raise.
The example is source-reviewed only; no Variant conversion was executed.
External references
Created 2026-07-15