DOpus.listers: tips and oddities

While writing CycleListers I stumbled upon a few things worth mentioning:

:one:

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.

for (var i = 0; i < DOpus.listers.count; i++) {
    DOpus.Output(DOpus.listers(i));
}

I don't think this info is in the docs.

:two:

The only way to bring a lister to the front seems to be

cmd.SetSourceTab(DOpus.listers(listerToActivate).activetab);
cmd.RunCommand('Set LISTERCMD=tofront');

I never got this or any variation working:

DOpus.listers.ToFront(DOpus.listers(listerToActivate));

:three:

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;
}

but being able to check with

if (DOpus.listers(lister)) ...

would be nicer.

2 Likes

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! :laughing:

1 Like