Variants
Variant Type
Variant variables are capable of storing values that change type dynamically. Variables of any other type (Integer, String, Date, etc.) are statically bound to that type, but a variable of the Variant type can assume values of differing types at runtime.
You would use a Variant in situations where the actual type of your data is unknown at compile-time. This is a common situation when writing applications that use COM objects.
Variants have the following characteristics:
- Variants can contain Integer, Number, Real, Boolean, Date, Time, TimeSpan, DateTime, String, RowId, Handle, and IDispatch pointer values.
- The special Variant value
OLE_VT_EMPTYis used to indicate that a Variant has not yet been assigned any value.Variant.pkgmust be used to useOLE_VT_EMPTY. - Variants can be combined with other Variants and Integer, String, Boolean, etc. values in an expression. The DataFlex expression evaluator will automatically perform the necessary type conversions.
- When a Variant contains a reference to a COM Object (
IDispatch*), it automatically performs reference counting for the referenced object.
Note
For more information, refer to Declaring Variables, the Variant command, and Using Variant Data Types with COM.