RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
Variants.Unassigned Function

Returns an "empty" variant.

Pascal
function Unassigned: Variant;
C++
Variant Unassigned();

A variant variable can be "empty", meaning it has not yet been assigned to. The Unassigned function returns an empty variant, which can be assigned to a variant variable to restore the variable to its initial state. 

Use the VarIsEmpty function to test whether a variant is empty. When used on an empty variant, the VarType standard function returns varEmpty

If an empty variant is cast to another type (for example, by assigning to a non-variant variable or calling VarAsType) the following conversions occur:

Destination 
Conversion result 
Numeric type  
Zero  
String type  
Empty string  
Boolean  
False.  

Note: Unassigned is useful with variants referencing OLE Automation Objects that you want to keep "alive" until another value is assigned to the variant.
There's corresponding functionality under Linux. Should document when time permits. 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!