RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCustomVariantType.Compare Method

Implements comparisons that involve the custom System::Variant type.

Pascal
procedure Compare(const Left: TVarData; const Right: TVarData; var Relationship: TVarCompareResult); virtual;
C++
virtual __fastcall Compare(const TVarData Left, const TVarData Right, TVarCompareResult Relationship);

Override Compare to implement any comparison operators the custom System::Variant type supports. Descendants can implement comparison operators by overriding either the Compare or the CompareOp method.  

Left is the value that appears to the left of the operator. 

Right is the value that appears to the right of the operator. 

Relationship returns a value indicating the relationship between Left and Right, as indicated in the following table:

Value 
Operation 
crLessThan  
Left is less than Right.  
crEqual  
Left is equal to Right.  
crGreaterThan  
Left is greater than Right.  

As implemented in TCustomVariantType, CompareOp raises a system error indicating an invalid operation.

Tip: For custom Variants that support a test of inequality, but not ordering, it makes more sense to override the CompareOp method instead.
 

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