realbasic-nug
[Top] [All Lists]

Operator_Compare with variant objects?

To: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Subject: Operator_Compare with variant objects?
From: Michael Diehr <md03@xochi.com>
Date: Sat, 30 May 2009 10:34:08 -0700
Authentication-results: mx.google.com; spf=neutral (google.com: 74.124.194.228 is neither permitted nor denied by best guess record for domain of realbasic-nug-bounces@lists.realsoftware.com) smtp.mail=realbasic-nug-bounces@lists.realsoftware.com
Delivered-to: listarchive@realsoftware.com
Reply-to: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Sender: realbasic-nug-bounces@lists.realsoftware.com
If a variant holds an object, then Variant.StringValue will automatically call Operator_Convert for the object (assuming it has "Operator_Convert() as string" defined).

However, this does not seem to hold true for Operator_Compare when comparing variants.

Am I doing something wrong or is this just how it goes?

Code:

 dim v1 as variant = new cMyClass
 dim v2 as variant = new cMyClass

 // this calls cMyClass.Operator_Convert
 if v1.stringValue = v2.StringValue then ...

 // this does NOT call cMyClass.Operator_Copmare
 if v1 <> v2 then ...

Class cMyClass
 function Operator_Convert() as string
   return "foobar"
 end function

 function Operator_Compare(rhs as cMyClass) as integer
   return -1
 end function



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>