While writing CycleListers I stumbled upon a few things worth mentioning:
Listers from the DOpus.listers collection can be referenced by their collection index as well as their Windows handle HWND which is their default property.
Referencing a lister via DOpus.listers(lister) will result in an out-of-range JScript error if the lister does not exist.
We can check with a function like
function ListerExists(listerID) {
for (var i = 0; i < DOpus.listers.count; i++) {
if (String(DOpus.listers(i)) == String(listerID)) return true;
}
return false;
}
Thank you, this was really helpful! As usual, I should have searched more before trying to solve everything on my own...
As a small addition to your second point: You can also bring a lister to the front by running Go FINDTITLE, but it obviously only works if the title is known to your script (and you'd likely want it to be unique).
I was trying to lock two listers together so that when I activated lister A it would also make lister B visible but then return to lister A. In the OnActivateLister event handler, I ended up running a Go FINDTITLE command to find lister B and then Set LISTERCMD=ToFront (see above) for lister A, which worked just fine except that the return to lister A would, of course, result in another call to OnActivateLister, starting the whole thing all over again...
Finally, to my considerable relief, I found the parameter "NOSCRIPT", as in Set LISTERCMD=ToFront NOSCRIPT
This keeps OnActivateLister from being called. WHEW!
1 - Added a note to Scripting Objects [Directory Opus Manual] about referencing collection objects by their index (doesn't just apply to Listers - any collection can be indexed this way)
2 - Fixed in the next beta
3 - Added Listers.Exists() method in the next beta to check if a Lister object or index is valid