realbasic-nug
[Top] [All Lists]

Re: Operator_Compare with variant objects?

To: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Subject: Re: Operator_Compare with variant objects?
From: Norman Palardy <npalardy@great-white-software.com>
Date: Sat, 30 May 2009 15:20:42 -0600
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
In-reply-to: <9142A64B-6ACF-4072-B847-82A5C7098969@xochi.com>
References: <AEF09038-DB63-4857-BBE1-AE5D13AA6FF3@xochi.com> <3AA0AEC2-D230-4A4C-8788-84C3FCC17A44@great-white-software.com> <9142A64B-6ACF-4072-B847-82A5C7098969@xochi.com>
Reply-to: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Sender: realbasic-nug-bounces@lists.realsoftware.com

On 30-May-09, at 12:49 PM, Michael Diehr wrote:

What, no ESP module?   :)

Nope and no magic allowed either :P

Is there any way to get around this by telling the compiler what I want?

I tried casting to generic objects, but that didn't work, e.g.
 if v1.type = variant.TypeObject then
    dim o1,o2 as object
    o1 = v1.objectValue
    o2 = v2.objectValue
    if o1 = o2 // still doesn't call the Operator_Compare

= for objects simply compares generic Object references (are they the same reference)

The only way I can make it work is to explicitly cast to the object class, but that's inelegant as it is no longer generic code and requires a giant Case statement:

 if v1.type = variant.TypeObject then
   select case v1.objectValue
   case isa cClass1
      dim o1 as cClass1 = v1
      dim o2 as cClass1 = v2
      if o1 = o2 // NOW we get the the Operator_Compare() called
   case isa cClass2
      [...]
   case isa cClass3
      [...]

I haven't tried it but I suspect

    if v1.operator_compare(v2) ......

would do

_______________________________________________
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>