I have two general-purpose ScriptUI palettes (one for Indesign and one for InCopy) that calls a smaller palette (which works in both applications) using a doScript() command. I've done the same thing for ScriptUI dialogs, which works just fine because the dialog must be dismissed before the user can do anything else.
With a floating palette, though, the "big" script can call multiple instances of the little one. This is probably a silly thing to worry about, but it just seems sloppy to allow that.
So I'm looking for a way to test whether the little palette is open. I don't think these ScriptUI windows show up in the app.panels array.
The best I've come up with so far is:
if (ntWindowShowing==undefined) {
ntWindow.show();
ntWindowShowing = true; }
near the top of the little script, after the "ntWindow" palette is defined. Later, there's an onClose handler that sets ntWindowShowing to undefined. It seems to work OK, but I wonder if anyone has a better solution. I recall an admonition to avoid switching a variable from one data type to another but wonder if there's any harm in going from undefined to true to undefined again.
Didn't exactly set off a debate over best practices. Oh well.
I realized today that the if statement should be:
if (typeof ntWindowShowing=="undefined")
otherwise the script throws an error after a restart of the application. Seems to have something to do with the difference between an undeclared variable and an undefined one.