System.Variants.Unassigned

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function Unassigned: Variant;

C++

extern DELPHI_PACKAGE System::Variant __fastcall Unassigned(void);

Properties

Type Visibility Source Unit Parent
function public
System.Variants.pas
System.Variants.hpp
System.Variants System.Variants

Description

Returns an "empty" variant.

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.

See Also