This revsion fix an error situation which I discover using casting on objects. So this normaly never happen. But the interesting part is I find some unexpected behaviour of Visual Basic 6. M2000 Interpereter compiled as an activeX dll from VB6. The M2000.exe is a small program which load this dll. (you can use M2000 as an object from another language)
I named this situation as Bomb Situation, because previous revisions hang on Type(testme) function. The reason? I don't now why but I now how this repeated. The testme object is the same as the object a, but they have different vtables, so they have differnt interfaces. Ok this not bad. The later interface (on testme object) call the value property. Normaly to call this property you have to know what to call, and as anyone expect the VB6 compiler knows what to call, and place the code to do that, using the idispatch interface. Interfaces are choosen by the QueryInterface function (the first function on vtable). So why this not happen? Maybe the vtable isn't what expected because of casting. The solution was simple, I do manualy the casting to idispatch interface before using the Typename(vv.value) where vv is the object and value the property. The idea behind interfaces is that from any interface you can get any other interface if the object support it. You can't get a list of interfaces; You have to pass a 256bit number to find if supported. This number is to big. It is better to follow the code to find what compare...This is something for other time.
' The Bomb Situation, or you need a lifetime or more to understand how VB6
' I think this can't be found from AI
Cast =lambda (that$)->{
Interface that, that$ {dummy}
=lambda that (t as *that)->t
}
get_iUnknown = Cast("{00000000-0000-0000-C000-000000000046}")
' buffer object has functions to read memory everywhere;
' (checking for bad address first)
buffer inspect as long
declare form1 form
declare a type "ctxninebutton" form form1
testme = get_iUnknown(a)
? "These have different VTables"
vtable_a=inspect=>peekint32(varptr(a))
vtable_testme=inspect=>peekint32(varptr(testme))
? "Same Objects: ";testme is a
? "Different VTables: "; vtable_a<>vtable_testme
if version<15 or (version=15 and revision<29) then "do not do this - program hang": exit
? type(testme)
' why ? old one hang? Who knows..
' how overcame this problem?
' This problem was for the ExtControl class (see ExtControl.cls), the real class behind external controls.
' Type() didn't return ExtControl but go deeper and get the value property.
' This value property is the ctxninebutton (the usectxninebutton.ctl)
' So when we use Type(a) M2000 get the value of object and return ctxninebutton
' When we get the iUnkown interface, we get different Vbtable.
' That is not bad as idea, but for this control the use of value property hang the program.
' The solution was to get the iDispatch interface and then use on that the value property.
declare form1 nothing

