Variants in Delphi. Use of Variant Array. How to check a Variant is unassigned or empty or clear ?
Sometimes it is necessary to store and change data whose type varies or cannot be determined at compile time. In these cases, we can use variables and parameters of type Variant, which represents values that can change type at run time. Variants are used to store any data type value and can perform numerous operations at run time. For variants type values the compiler automatically performs type conversions. Once you have the variant value, you can assign it to any compatible-or incompatible-data type. If you assign a value to an incompatible data type, Delphi performs a conversion, if it can. Otherwise it issues a run-time error. By default, Variants can hold values of any type except records, sets, static arrays, files, classes, class references, and pointers. Use System.Variants unit. Example We declare a variant variable such as the following: var V: Variant; You can assign to it values of several different types: V := UnAssigned; V := NULL; ...