On Mar 27, 2006, at 3:46 PM, Charles Yeomans wrote:


On Mar 27, 2006, at 4:29 PM, William Squires wrote:

On Mar 26, 2006, at 5:50 PM, Charles Yeomans wrote:


On Mar 26, 2006, at 5:20 PM, William Squires wrote:

Given an array of type <reference-to-baseclass> (whatever 'baseclass' happens to be), and some instances of the base class (and subclasses thereof) stored in an array, fMyArray; when I step through the array like so:

Dim i As Integer
Dim l As Integer
Dim theItem As BaseClass
Dim theSubclassItem As Subclass

If (fNumItems > 0) Then
  l = fNumItems - 1
  For i = 0 To l
    theItem = fMyArray(i)
    If (theItem IsA Subclass) Then
      // Shouldn't this work?
      theSubclassItem = Subclass(theItem)
      theSubclassItem.DoSubclassThing()
    Else
      // tests for other subclasses...
    End If
  Next
End If

shouldn't IsA tell me if the instance referred to by 'theItem' (after the assignment from the array) is really an instance of BaseClass or Subclass, even though the compile-time type of 'theItem' is 'BaseClass' (and ditto for the array, since otherwise you wouldn't be able to store base class instances in it if you DIMmed it as a compile-time type of one of BaseClass' subclasses.)? i.e. shouldn't IsA work polymorphicly?

Yes, the code above should work as you expect.

But apparently doesn't in RB 5.2.4 (Win) and compiled to Windows (WinXP box). See the previous message thread, "IsA isn't."

Well, it does in the current version of REALbasic on MacOS X. Perhaps you should upgrade. Otherwise, it would be helpful for you to note that you're using an out-of-date version of REALbasic, so that I'd know not to spend time answering.

Actually, I already have a license for RB2006 (OS X - my home computer), but that won't do me much good on my XP box at work... :)

--------------
Charles Yeomans

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

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


William H Squires Jr
4400 Horizon Hill #4006
San Antonio, TX 78229
[EMAIL PROTECTED] <- remove the .nospam

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

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to