What is the code for getting the title (or whatever) from a weakRef to a window?
I would like to use this in an array of Weakref’s to windows
Var wdw As New Window
Var wrf As New WeakRef(wdw)
If “blank” = wrf.Title Then //This code doesn’t work)
What do I write instead of wrf.Title?
var wr as WeakRef = weakRefArr( x )
var w as Window = Window( wr.Value ) // Will be nil if the Window is gone
if w isa Window and w.Title = "blank" then
...
Thank you. That second line is what got me.
Basically what you do is rebuild what you put in to the array.
Cast it, not rebuild, but I think you get it.
1 Like
Make sure you check if wr is nil as well!
3 Likes
Wow, I tried to do it as “wr.Value” and it wouldn’t work. Of course, because I’m casting, but there is no room for cheating.
Update. Grumble. In the array when I test for Nil for the weakRef, it’s not what I thought.
Example where CDsw is the array of WeakRefs
//It's NOT
If CDsw(i) = Nil Then
CDsw.RemoveAt(i)
//Rather
If CDsw(i).Value = Nil Then
CDsw.RemoveAt(i)
Actually… you need to test both.
DerkJ
(DerkJ)
March 7, 2021, 3:26pm
9
You are safe using (order of this line is important):
If CDsw(i) = Nil or CDsw(i).value = Nil Then
CDsw.RemoveAt(i)
end if
When reading/casting i’d suggest you do type checking to using IsA
1 Like