obj IsA xxx

Shouldn’t this be IMPOSSIBLE?

if obj isa ArcShape and obj isa RectShape then msgbox “Huh?”

It is one OR the other … it can’t be BOTH

Try running this:

[code] Dim A as New ArcShape
Dim R as New RectShape

Dim Msg() as String

If A isA RectShape Then
Msg.Append “An ArcShape is a RectShape!”
Else
Msg.Append “An ArcShape is NOT a RectShape!”
End if

If R isA ArcShape Then
Msg.Append “A RectShape is an ArcShape !”
Else
Msg.Append “A RectShape is NOT an ArcShape !”
End if

MsgBox Join(Msg, EndOfLine)
[/code]

An ArcShape isA RectShape but a RectShape is not an ArcShape… which may suggest a workaround

Thanks… I found a similar work-around…

This is part of my PDF class… where I am deconstructing a Group2D
so I have code like this… added EXIT SUB and made sure IsA RectShape is last on the list

but it is still a bug

  If obj IsA ArcShape Then 
    PDF_DrawShape ArcShape(obj),parent
    exit sub <<<<<<---- WORK AROUND :)
  End If
  If obj IsA CurveShape Then
    PDF_DrawShape CurveShape(obj),offset_x,offset_y,offset_r
  End If
  If obj IsA OvalShape Then 
    PDF_DrawShape OvalShape(obj),offset_x,offset_y,offset_r
  End If
  If obj IsA PixmapShape Then
    PDF_DrawShape PixmapShape(obj),offset_x,offset_y,offset_r
  End If
  
  If obj IsA RoundRectShape Then 
    PDF_DrawShape RoundRectShape(obj),offset_x,offset_y,offset_r
  End If
  If obj IsA StringShape Then 
    PDF_DrawShape StringShape(obj),offset_x,offset_y,offset_r
  End If
  If obj IsA RectShape Then
    PDF_DrawShape RectShape(obj),parent
  End If

Have you tried your code with an oval shape? You should find that it will be both an oval shape and a rect shape. The problem here is that an object with test true with IsA if its superclass (or a super class to that, etc) is tested for. What I would probably do is draw out the whole object2D inheritance and build your “if tests” from there. Something like:

if obj IsA rectShape then
   if obj IsA ovalShape then
      if obj IsA arcShape then
         //arcShape
      else
         //ovalShape
      end if
   else
      //rectshape
   end if
end if

Except you will have to do it for all of the object2D inheritance.

here is the tree is anyone else is interested



obj2d
|
+---RectShape
|    |
|    +-oval
|    | |
|    | +-ArcShape
|    |
|    +-PixMapShape
|    |
|    +-RoundRectShape
|
+-Curveshape
|
+-FigureShape
|
+-StringShape

I am rearranging the IsA checks to check from the end of the branch towards the trunk of the tree

[quote=55579:@Dave S]Shouldn’t this be IMPOSSIBLE?

if obj isa ArcShape and obj isa RectShape then msgbox “Huh?”

It is one OR the other … it can’t be BOTH[/quote]

Both are superclasses, hence the AND statement is correct.

  dim o as new ArcShape

  if o isa ArcShape AND o isa OvalShape AND o isa RectShape and o isa Object2D then
    System.DebugLog "OK"
  end if

Not sure what you consider the bug to be ?
If I have

Class1
Class2 inherits Class1 (its a subclass of class1)
Class3 inherits Class2 (its a subclass of class2)

Then
dim myC3 as New Class3
if myC3 isA Class3 then msgbox “isa Class3” // true
if myC3 isA Class2 then msgbox “isa Class2” // true
if myC3 isA Class1 then msgbox “isa Class1” // true

dim myC2 as New Class2
if myC2 isA Class3 then msgbox "isa Class3" // FALSE
if myC2 isA Class2 then msgbox "isa Class2" // true
if myC2 isA Class1 then msgbox "isa Class1" // true

dim myC1 as New Class1
if myC1 isA Class3 then msgbox "isa Class3" // FALSE
if myC1 isA Class2 then msgbox "isa Class2" // FALSE
if myC1 isA Class1 then msgbox "isa Class1" // true

Ok… so it is not a bug…it was a misunderstanding that lead to confusion, that was cleared up hours ago.