I use Window(0) on a three window app to make sure that I open my custom dialogs with “ShowWithin” in the proper window. I made a change to a function that shows the dialog which changes a couple of values shown depending on which window is Window(0). Unfortunately, I’m now greeted with the first tested window no matter which one is actually Window(0) because the test invokes the window tested against.
Is it possible to test for a window’s presence without causing it to open without needing to rewrite major chunks of code to use non-implicit instances?
I use Window(0) on a three window app to make sure that I open my custom dialogs with “ShowWithin” in the proper window. I made a change to a function that shows the dialog which changes a couple of values shown depending on which window is Window(0). Unfortunately, I’m now greeted with the first tested window no matter which one is actually Window(0) because the test invokes the window tested against.
Is it possible to test for a window’s presence without causing it to open without needing to rewrite major chunks of code to use non-implicit instances?[/quote]
Calling anything in a window will instantiate anyway. The only solution I see is to keep a copy of the properties in the windows you need to test, and test the copies instead of the actual windows properties.
Michel, I don’t follow how that relates to the question of determining which window is at window(0). Once you have determined which window you’re dealing with, you can access its properties without instantiating it (because it’s already instantiated at window(0).
if window(0) isa Window1 then
Window1(window(0)).someproperty = somevalue
elseif window(0) isa Window2 then
Window2(window(0)).otherproperty = othervalue
end
None of that will trigger implicit instantiation. And it will work even if you use explicit instantiation, so you’re covered both ways.
= is “are these referring to the same object” and can cause an instance to be created to do the comparison
With implicit instantiation code like
if Window(0) = Window1
breaks down into something like
- get the reference from Window(0)
- get the singleton reference by calling the global method “Window1”
- if this method does NOT currently have a reference to the singleton (it’s nil) then create one
- compare the two references to see if they refer to the same object
so you see where the new instance comes from
isa is “it this reference referring to an object of this type” - and in this case there is NO access to the singleton or the global method