RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
VarConv.VarAsConvert Function

Casts an arbitrary Variant so that it is a custom Variant representing a measurement.

Pascal
function VarAsConvert(const AValue: Variant): Variant; overload;
function VarAsConvert(const AValue: Variant; const AType: TConvType): Variant; overload;
C++
Variant VarAsConvert(const Variant AValue);
Variant VarAsConvert(const Variant AValue, const TConvType AType);

VarConv

VarAsConvert converts the Variant specified by AValue to a VarConvert custom Variant. 

Using the first syntax, AValue is interpreted as the numeric portion (the number of units), and AType identifies the units. 

Using the second syntax, AValue should be a Variant that can be parsed into a VarConv custom Variant (for example, a variant whose value is a string such as '1.5 miles'). 

If VarAsConvert can't perform the conversion, it raises an EInvalidCast exception. 

VarConvert custom Variants represent measurements (that is, a type of measurement units and the number of those units). The units must be registered measurement units such as those used by the ConvUtils unit. You can use the negation operator on VarConv variants, and use the addition, subtraction, multiplication, division, and comparison operators on a VarConv Variant with a real number. You can use the addition, subtraction, division, and comparison operators on two VarConv Variants. VarConv custom Variants also support the following properties: 

Value is the numeric portion (the number of units). (read/write) 

Type is units. (read-only) 

TypeName is the name of the units. (read-only). 

Family is the conversion family of the units (the thing measured). (read-only). 

FamilyName is the name of the conversion family. (read-only) 

Depending on the Family, each Variant has a set of conversion properties with names of the form As<Unit>, where <Unit> is the name of another type of unit in the same conversion family. 

 

EInvalidCast 

VarIsConvert 

VarConvertCreate 

VarAsType 

TVarData

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!