I shouldn’t have restricted it to form windows. Any window can be renamed to any name with the windowname statement. For example, here is a data sheet.
By running the code:
windowname "Fake Window Name"
I now have this window:
If I already had a database open with the name Fake Window Name, it would now appear that I have two data sheets open with that name.
I’m not saying that you necessarily are doing this, just pointing out that two windows with the same name doesn’t mean that two files have the same name.
F3 is Expose, correct? I don’t usually use the Fn keys, but it appears to be expose on my system.
So when you way you have two “databases”, I think you are meaning to say that you have two data sheets with the Tickers name. Assuming you didn’t use the windowname statement, this would probably mean that at some point Panorama got confused and allowed the same database to be opened twice in separate internal (in-memory) data structures. This is not supposed to ever happen – the first thing the open database code does is check to see if the database is already open. But for some reason this check isn’t finding a match.
I tried experimenting with the closedatabase and closefile statements to see if I could duplicate this problem, but I couldn’t get either of these to fail in this way (or fail at all). I did verify that the closedatabase statement works fine when used with the active database.
So I think something in your 900 lines of code is messing up the internal structure that Panorama uses to manage open databases.
You should be able to check the number of Tickers data sheet windows with this formula.
linecount(arraystrip(arrayfilter(info("windows"),cr(),{?(import() match "Tickers",import(),"")}),cr()))
You could create a mini-procedure at the end of your big procedure like this:
checkTickers:
let tickerWindows = linecount(arraystrip(arrayfilter(info("windows"),cr(),{?(import() match "Tickers",import(),"")}),cr()))
if tickerWindows > 1
message "Extra ticker at "+parameter(1)
stop
endif
return
Then, at various spots you could call the subtoutine this like this
shortcall checkTickers,"spot ABC"
...
shortcall checkTickers,"spot DEF"
...
shortcall checkTickers,"spot XYZ"
As soon as more than one Tickers window is detected, the procedure will stop and display a message indicating where the problem is. Whatever the problem is, it must be in the code above where the shortcall statement was. Since apparently Panorama’s internal memory structure is compromised, I would suggest quitting and relaunching Panorama after each time you run this test.
You can start with just a few shortcalls to this mini-procedure, then keep adding more as you learn what the target area is.
It’s possible (even probable) that the actual problem is caused before the duplicate window symptom appears. So this probably won’t find the exact line of the problem. But the problem is definitely not caused after the duplicate window shows up, so this should definitely narrow down the scope of the search for this problem.