Can I limit the maximum number of open folder tabs?

I have looked through the preferences but was unable to find a setting. However, I may have well missed it if it is there as the possible settings/tweaks are overwhelming.

Please help!

No, at least not without writing a script.

What are you doing that results in so many tabs being open? Maybe there is a way to avoid the problem before it happens.

May I ask how to use the script to achive this (for example, I want to limit the number of each window tabs up to more than 5)

[quote="leo"]No, at least not without writing a script.

What are you doing that results in so many tabs being open? Maybe there is a way to avoid the problem before it happens.[/quote]
As usual work frequently used DO, generated a lot of tabs in the frequent use of the process

I don't think trying this with the events that are currently defined would be very smooth... I think we'd want to have some sort of OnBeforeOpenTab event... which we could use in similar fashion to OnBeforeFolderChange. My thinking behind this is:

If you want to limit the number of tabs you can have open at one time in a lister... then you really want a way to STOP a tab from opening in the current lister once your MAXTABS value is reached, where you can then decide to do "something else". But I don't see any way of doing that using any of the existing events. The only thing I can think of would be to use the current OnOpenTab event, which when fired - we could then use to check the number of open tabs in the current lister against a MAXTABS value.

You'd naturally then need to decide what to do if your MAXTABS value has in fact been reached. As things stand now I think the best you could do is have the script first CLOSE the tab that was just opened and then decide if you wanted to do something else instead (such as open the same folder path as a new tab in ANOTHER lister with fewer than MAXTABS open).

So the new tab would momentarily be opened in the current lister... then closed, causing some momentary visual jerkiness. But maybe thats a trivial trade-off in order to get what you want. Here's a sample script which shows there might be a few problems in the scripting interfaces being used:

[code]Option Explicit
' Called by Directory Opus to initialize the script
Function OnInit(ByRef initData)

' Provide basic information about the Script = "OnOpenTab_vbtest"
initData.desc = "Adds an 'OnOpenTab_vbtest' event handler to Directory Opus."
initData.copyright = "(c) 2014 steje"
initData.version = "v1.0.0 (vb)"
initData.default_enable = True

' Set DEBUG flag below to true in order to enable logging messages to the Opus Output Window
initData.config.DEBUG = True
' Create a ScriptConfig property of type VT_I4 to use as a control for how many tabs can be opened
initData.config.MaxTabs = 5

End Function

' Called before a folder has been opened
Function OnOpenTab(ByRef openTabData)

Dim message
message = ""
Const vbQuote = """"


' Command stuff
Dim objCmd, strPath, strCommand
logMsg("Script.config.MaxTabs: " & Script.config.MaxTabs)
logMsg(" " &

If (Script.config.MaxTabs > 0) And ( > Script.config.MaxTabs) Then
Set objCmd = DOpus.CreateCommand
strPath =
logMsg("Newtab path: " & strPath)
objCmd.RunCommand("Go TABCLOSE")
logMsg("MaxTabs is ok")
End If

logMsg("------------End------------" & vbCrLf)

End Function

' Subroutine to allow toggling of the global VT_BOOL variable to control whether logging is performed or not
Sub logMsg(message)

If (Script.config.DEBUG) Then DOpus.Output(message)

End Sub[/code]

This example OnOpenTab event handler script does just about half the job:

[ul][li]gives you a user-configurable numeric value (MaxTabs) to control how many tabs you'll allow to be opened in any lister[/li]
[li]checks to see how many tabs are open at the point when each new tab is opened[/li]
[li]if the number of tabs is greater than the MaxTabs value, close the new tab that was just opened[/li][/ul]
From there, some further work would need to be done to figure out how to choose another lister (if some other listers are already open) in which to open the new tab in instead of the current lister. I'm just guessing that's what you wanted to have happen though...

However, with this sample script I've found a few problems that I think are bugs:

1.) Sometimes, the value of seems to be wrong - haven't quite figured out the circumstances for it yet - but its only happened in dual-display mode in my limited testing so far. I'll have to figure out how to repro this on demand ;-(.
2.) My use of Go TABCLOSE isn't always working as expected... using objCmd.SetSourceTab( should ensure that a subsequent Go TABCLOSE command closes the tab that was just opened. In a dual-display lister, if the new tab I'm opening is being opened in the 'other' file display from a command like go newtab openindual, then the current source tab is closed, and the new tab opened in the other display is left open... which is wrong.

With a change made in 11.1 Beta 1, this works consistently now...

What do you want to do with the tab that you are trying to open once you reach the MAX tabs allowed for a lister? Simply open the same path in a NEW lister?