Small bug in script processing

Hello

I have a small script which checks if a window instance is already open to prevent opening another one again for the same pump. (I can have many instances but only for different pumps)

Each time I open a popup window I set a different title for the window (that includes the Pump Name) so I can later check if its already opened like this:

#Abre nueva instancia de la gráfica
param1 = event.source.parent.parent.Bomba #this is a UDT property

windows=system.gui.getOpenedWindows()
found=0
for window in windows:
    if (window.title=="Tendencias Históricas de la Bomba "+param1.Nombre):
       found=1
if (found==0):       
   system.nav.openWindowInstance('Historicos/Tendencias', {'Bomba' : param1})

I noticed that I get an error because of the accent in the word “Históricas” and if I change it to “Historicas” without accent it works OK.

This is the error:

Traceback (most recent call last):
  File "<event:mouseClicked>", line 8, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xf3 in position 15: ordinal not in range(128)

I also noticed that it doesn’t matter if the window.title property has accent or not, but the problem is in the comparison with the string written in the script, if it has accent the error pops up.

Regards

The problem is you have a unicode character “ó” in your string. You can try doing this:if (window.title== u"Tendencias Históricas de la Bomba "+param1.Nombre):It would probably be better to check the param you pass in rather than checking the title of the window. I would try this:[code]#Abre nueva instancia de la gráfica
param1 = event.source.parent.parent.Bomba #this is a UDT property

windows=system.gui.getOpenedWindows()
found=0
for window in windows:
if (window.getRootContainer().Bomba.Nombre == param1.Nombre):
found=1
if (found==0):
system.nav.openWindowInstance(‘Historicos/Tendencias’, {‘Bomba’ : param1})[/code]

Travis you’re a Genius!

That is much more elegant.

Thank you!