TVarType
TVarType = Word
Example
procedure ReadVariantType(Value: Variant; var TypeCode: TVarType);
begin
TypeCode := VarType(Value);
end;
Usage
TVarType stores the raw 16-bit Variant base code and representation flags returned by VarType.
Additional Technical Info
TVarType is an unsigned 16-bit Word used for a Variant's physical type metadata. VarType returns the raw top-level TVarData.VType field without conversion, masking or dereferencing.
It is not a closed enumeration. The low 12 bits hold a built-in or custom base number; higher bits can describe representation:
Code := VarType(Value);
Base := Code and varTypeMask;
IsArray := (Code and varArray) <> 0;
IsByRef := (Code and varByRef) <> 0;
| Role | Registered members |
|---|---|
| Empty/missing | varEmpty, varNull |
| Signed integers | varShortInt, varSmallInt, varInteger, varInt64 |
| Unsigned integers | varByte, varWord, varLongWord |
| Floating/fixed/date | varSingle, varDouble, varCurrency, varDate |
| Strings | varOleStr, varString, varUString, internal varStrArg |
| Interfaces/status | varDispatch, varUnknown, varError |
| Nested/special | varVariant, host-managed varAny |
| Mask/flags | varTypeMask, varArray, varByRef |
Important implementation rules
- Velox registers exactly the constants listed above. Current Delphi also defines
varUInt32,varUInt64,varRecord,varObject,varUStrArgand custom-type ranges, but those names are not script-visible.varLongWordis the exposed legacy alias for current code 19/varUInt32. varArrayandvarByRefare flags, not standalone base types. Mask for the base and test each flag separately. Array flags do not provide bounds, dimensions, locks or ownership.- A raw
varByRef or varVariantwrapper can differ from its referent. Several Delphi predicates resolve that wrapper withFindVarData;VarTypeintentionally does not. - With Delphi's default
PackVarCreation=True, equal numeric values can have different exact integer/floating tags according to their source and range. Use exact codes for representation decisions, not as the only business numeric test. - Pascal strings, arrays, interfaces and Any values have managed or borrowed lifetimes. A type code does not prove payload validity, safe retention, thread safety or absence of side effects.
varEmptyis uninitialised/cleared;varNullis explicitly missing. Converting either to a default value can erase that distinction.
Compare symbolic constants rather than hard-coded numbers. Do not persist a TVarType as a cross-language schema without a versioned contract.
The example is source-reviewed only; no Variant tag was read.
External references
Created 2026-07-15