Sign in Join
FPDoc Onlineexperiment

Variants unit

Extended variants support.

The compiler has built-in support for variants, and for many operations, variants can be used without thinking about it. The system unit has built-in support for some of the basic operations on a variant, as well as some compiler helper routines. However, some operations and definitions are implemented in the Variants unit so as not to burden the system unit with routines that may not always be needed.

There is a basic set of variants that are defined by the Windows OS, these are supported by the compiler and the routines in the Variants unit. Additional variant types can be registered using the TCustomVariantType type.

The variants unit also registers a handler for setting published properties (using RTTI) using variant-typed values. Nothing needs to be done for this except including the variants unit in your program.

Classes and records

EVariantArrayCreateErrorclassError raised when a problem is detected during creation of an array.
EVariantArrayLockedErrorclassError raised when an operation on a locked array is performed.
EVariantBadIndexErrorclassError raised when an invalid array index is detected.
EVariantBadVarTypeErrorclass>Error raised when an invalid variant type is detected.
EVariantDispatchErrorclassException raised in case of variant dispatching errors.
EVariantInvalidArgErrorclassError raised when an invalid argument is detected.
EVariantInvalidNullOpErrorclassVariant invalid null operation error.
EVariantInvalidOpErrorclassError raised when an invalid operation is performed.
EVariantNotAnArrayErrorclassError raised when an array operation is performed on a non-array variant.
EVariantNotImplErrorclassError raised when a variant operation not implemented.
EVariantOutOfMemoryErrorclassError to signal an out-of-memory condition.
EVariantOverflowErrorclassError raised when an overflow error is detected.
EVariantParamNotFoundErrorclassError raised when a parameter is not found.
EVariantRangeCheckErrorclassException class to signal range checks.
EVariantTypeCastErrorclassError raised when an invalid typecast is performed.
EVariantUnexpectedErrorclassException raised during unexpected error.
IVarInstanceReferenceinterfaceInterface for variants that refer to an object.
IVarInvokeableinterfaceInterface needed for custom variants that need to implement dynamic properties and methods.
TCustomVariantTypeclassBase class for a custom variant type.
TInvokeableVariantTypeclassTCustomVariantType descendent that implements DispInvoke.
TPublishableVariantTypeclassTInvokeableVariantType descendent that implements reading published properties.

Procedures and functions

assign(TNullPtr):Variantoperator
DynArrayFromVariantprocedureConvert a variant to a dynamic arrayt.
DynArrayToVariantprocedureConvert a Dynamic Array To a Variant.
FindCustomVariantTypefunctionFind a custom variant class on vartype.
FindVarDatafunctionReturn a pointer to variant data.
GetPropValuefunctionReturn a property value as a variant.
GetVariantPropfunctionGet variant valued property.
HandleConversionExceptionprocedureConvert an exception to a variant exception.
NullfunctionReturn a null variant.
SetClearVarToEmptyParamprocedureCreate an error variant with value VAR_PARAMNOTFOUND.
SetPropValueprocedureSet a property value as a variant.
SetVariantPropprocedureSet variant valued property.
UnassignedfunctionReturn an unassigned variant.
VarArrayAsPSafeArrayfunctionReturn internal array of variant value.
VarArrayCreatefunctionCreate a variant array.
VarArrayCreateErrorprocedureRaise an EVariantArrayCreateError error.
VarArrayDimCountfunctionReturn the number of dimensions of the array.
VarArrayHighBoundfunctionReturn lower bound of an array.
VarArrayLockfunctionget a pointer to data of a variant array.
VarArrayLockedErrorprocedureRaise an EVariantArrayLockedError error.
VarArrayLowBoundfunctionReturn lower bound of an array.
VarArrayOffunctionCreate a variants array of a series of values.
VarArrayReffunctionGet a reference to a variant array.
VarArrayUnlockprocedureRelease data captured by VarArrayLock.
VarAsErrorfunctionCreate an error-typed variant.
VarAsTypefunctionAttempt to cast a variant to another type.
VarBadIndexErrorprocedureRaise an EVariantBadIndexError error.
VarBadTypeErrorprocedureRaise an EVariantBadVarTypeError error.
VarCastErrorprocedureRaise a variant type cast error EVariantTypeCastError.
VarCastErrorOleprocedureRaise a variant type cast error EVariantTypeCastError.
VarCheckEmptyprocedureRaise exception if a variant is empty.
VarClearprocedureClear the variant value.
VarCompareValuefunctionCompare 2 variant values.
VarCopyNoIndprocedureNot supported.
VarEnsureRangefunctionMake sure the variant is within a specified range.
VarFromDateTimefunctionCreate variant from TDateTime value.
VarInRangefunctionCheck if a variant is in a range of values.
VarInvalidArgErrorprocedureRaise an EVariantInvalidArgError error.
VarInvalidNullOpprocedureRaise an EVariantInvalidOpError error.
VarInvalidOpprocedureRaise a EVariantInvalidOpError error.
VarIsArrayfunctionCheck whether a variant is an array.
VarIsBoolfunctionCheck if the variant is a boolean.
VarIsByReffunctionCheck if the variant is a reference to a value.
VarIsClearfunctionCheck if a variant is clear.
VarIsCustomfunctionCheck if the variant is a custom value.
VarIsEmptyfunctionCheck if the variant is empty.
VarIsEmptyParamfunctionCheck if the variant is an error value for VAR_PARAMNOTFOUND.
VarIsErrorfunctionCheck if the variant has type varError.
VarIsFloatfunctionCheck if the variant is a floating-point value.
VarIsNullfunctionCheck if a variant is null.
VarIsNumericfunctionCheck if the variant is a numerical value.
VarIsOrdinalfunctionCheck if the variant is an ordinal value.
VarIsStrfunctionCheck if the variant is a string.
VarIsTypefunctionCheck if a variant is of certain type.
VarNotImplErrorprocedureRaise an EVariantNotImplError error.
VarOutOfMemoryErrorprocedureRaise an EVariantOutOfMemoryError error.
VarOverflowErrorprocedureRaise an EVariantOverflowError error.
VarRangeCheckErrorprocedureRaise an EVariantOverflowError error.
VarResultCheckprocedureCheck the result of an operation and raise exception if not OK.
VarSameValuefunctionCheck if 2 variants are the same.
VarSupportsfunctionCheck if a variant supports an interface.
VarToDateTimefunctionConvert a variant to datetime value.
VarToStrfunctionConvert a variant to string value.
VarToStrDeffunctionConvert a variant to string value, specifying a default.
VarToUnicodeStrfunctionConvert a variant to string value.
VarToUnicodeStrDeffunctionConvert a variant to string value, specifying a default.
VarToWideStrfunctionConvert a variant to string value.
VarToWideStrDeffunctionConvert a variant to string value, specifying a default.
VarTypefunctionReturn the type of a variant.
VarTypeAsTextfunctionReturn a textual description of the variant type.
VarTypeDeReffunctionReturns the resolved type of a variant.
VarTypeIsValidArrayTypefunctionCheck if a variant type can be used in an array.
VarTypeIsValidElementTypefunctionCheck if a variant type can be used in an array.
VarUnexpectedErrorprocedureRaise an EVariantUnexpectedError error.

Types

TAnyProcprocedure typeCallback handler to clear variants of type Any.
TBooleanToStringRuleenumerationEnumeration describing how to convert boolean values to string values.
TCustomVariantTypeClasstypeClass of TCustomVariantType.
TNullCompareRuleenumerationEnumeration describing how to handle Null values when comparing variants.
TVarCompareResultenumerationCompare 2 variant values.
TVarDataArraytypeDynamic array of vardata records.
TVarDispProcprocedure typeCallback to perform dispatch call on variant.
TVariantRelationshipenumerationEnumerated type to describe comparison operations between variants.

Constants

CFirstUserTypeconstantFirst allocated user type.
CIncVarTypeconstantIncrement above CMinVarType.
CMaxNumberOfCustomVarTypesconstantMaximum amount of custom variant types.
CMaxVarTypeconstantMaximum value for variant type.
CMinVarTypeconstantFirst allowed custom variant type index.
FloatVarTypesconstantConstant describing which variant types are considered floating point types.
OrdinalVarTypesconstantConstant describing which variant types are considered ordinals.
VarOpAsTextconstantNames of operations.

Variables

ChangeAnyProcvariableNot used.
ClearAnyProcvariableProcedure called to clear a variant.
EmptyParamvariableEmpty parameter variant.
InvalidCustomVariantTypevariableHandler for invalid custom variants.
NullAsStringValuevariableString value to use when converting a Null to a string.
NullEqualityRulevariableVariable describing what to do when checking for equality of Null values.
NullMagnitudeRulevariableVariable describing what to do when checking for order of Null values.
NullStrictConvertvariableWhat to do when converting Null to another type.
OleVariantInt64AsDoublevariableHow to convert Int64 variants.
PackVarCreationvariableSize to use when creating an array of integers.
RefAnyProcvariableHandler called to obtain a reference to a varAny typed variant.
VarDispProcvariableHandler called by DispInvoke.

Uses

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.