Window[] Returns NULL when it shouldn't

A forum for reporting bugs NOT related to custom plugins.

Moderator: MacroQuest Developers

ToVuNikaMua
decaying skeleton
decaying skeleton
Posts: 5
Joined: Fri Oct 31, 2003 6:21 pm

Window[] Returns NULL when it shouldn't

Post by ToVuNikaMua » Fri Jan 06, 2017 3:40 am

I've found a number of instances where Window[] returns null when it should return a valid window. I discovered this while trying to determine all the sub-sections of a window using recursion. A really simple way to show an example of this is the following lines of code:

Code: Select all

Sub Main
  /echo ${Window[TradeskillWnd].FirstChild.Next.FirstChild.FirstChild.Next.Name}
  /echo ${Window[${Window[TradeskillWnd].FirstChild.Next.FirstChild.FirstChild.Next.Name}].Name}

  /echo ${Window[TradeskillWnd].FirstChild.Next.FirstChild.Name}
  /echo ${Window[${Window[TradeskillWnd].FirstChild.Next.FirstChild.Name}].Name}
/return
In the first line we come to a sub-window of TradeskillWnd using the methods to traverse the relationship graph, and successfully echo it's name, COMBW_ContainerIcon, however if we wrap the value in another Window[] call and try to echo the name we get NULL. The last two lines show this is a valid technique for other steps. It would appear that Window[] can't find all the windows that should be available to it. The code that lead me to this discovery is the following:

Code: Select all

Sub Main
  /declare windArray[20] Window
  /declare level int outer 0
  /call PrintWindow TradeskillWnd ""
/return

Sub PrintWindow(Window wind, spacing)
  /declare tempstr string
  /varset tempstr ${spacing}${wind}
  /echo -${level}:${tempstr}

  /declare tempWind ${wind}
  /echo --Children: ${Window[${tempWind}].Children}
  /echo --Siblings: ${Window[${tempWind}].Siblings}

  /if (${Window[${tempWind}].Children} == NULL) {
    /echo ${Window[${tempWind}]}
  }

  /if (${Window[${tempWind}].Children}) {
    /call PrintWindow ${Window[${tempWind}].FirstChild.Name} ""
  }

  /if (${Window[${tempWind}].Siblings}) {
    /call PrintWindow ${Window[${tempWind}].Next.Name} "--"
  }

/return
It's a macro that attempts to traverse from the top of a Window hierarchy down to the children using recursion, printing each of the windows names along the way. I wasn't getting all the Window boxes I thought I should so I dug into some relationships by hand and noticed that my code stopped working when the Window[] function returned NULL on values it shouldn't.

Thanks







xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Window[] Returns NULL when it shouldn't

Post by xyilla » Sat Jan 17, 2026 11:58 pm