Automatically close existing lister when opening a new one

I am not sure if or how this might be possible.
Maybe via some script solution?
I frequently open a new lister from an existing one.
When I do this I want the current lister to close.
But not all existing listers just the currnet one.
By current I mean the lister from where I issued the command to open the new one.
Hope this makes sense.

I did a little testing and found this to work with a script.

function OnClick(data)
	var cmd = data.Func.command;
	cmd.RunCommand("Go NEW");

doesn't work with a standard function (non script) with raw commands.


Must only be working with the script version because it's running a seperate thread/process. The new lister might not open in the same location as the previous depending how it's being opened (for instance a layout).

This just demonstrating a basic close and open to show it works you can build off it from here.

Wonderful! I will play around with this thank you sir very kind

Taking a step back, what's the reason for opening a new window and closing the old one?

You may be able to change the old window into what you want instead, which would be more elegant.

Hi Leo
Missed your question for some reason.
I have see other posts about "Views" (?) as apposed to Listers and i got the point about possibly using that construct instead. Now I go looking I cannot find anything about the concept in the Opus help or these forums. do I have the right term?

With some effort I converted the Java script kindly provided by yonder and I could swear I got it working but I seem to have broken it again. Any ideas what is wrong with this? Much appreciated

The broken line should probably read..

cmd = clickData.Func.command

1 Like

OMG it worked! Thankyou aussieboykie
There was another problem as well "set" missing.
This is a working conversion to VB of yonder's Java script:

@script vbscript
Function OnClick(ByRef clickData)
    Dim cmd
	set cmd = clickData.Func.command
	cmd.RunCommand("Prefs LAYOUT dopusv")
End Function

Lister Styles or Lister Layouts may be what you want. Or something else.

What are you actually aiming to do?

Sample script which prompts for a new lister name, closes current lister and opens that new one here (below)
Thanks for the help...