DO11: scripting, triggering new tab by opening folder?

Encouraging initial results with this sample script:

[code]' OnBeforeFolderChange_xx:
' Revision: v1.0.0 (vb)
' (c) 2014 steje
'
' This is a script for written for Directory Opus v11.
' See http://www.gpsoft.com.au/redirect.asp?page=scripts for development information.

' =====================================================================================
' ====================== EVENT HANDLER: OnBeforeFolderChange ======================

' Called by Directory Opus to initialize the script
Function OnInit(ByRef initData)

DOpus.OutputString("Initializing..")

' Provide basic information about the Script
initData.name = "OnBeforeFolderChange_xx"
initData.desc = "Test Event Handler for BeforeFolderChange event..."
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

End Function

' Called whenever the folder is changed
Function OnBeforeFolderChange(ByRef beforeFolderChangeData)

Dim path, strCommand
path = beforeFolderChangeData.path
Set objCmd = DOpus.CreateCommand
objCmd.SetSourceTab(beforeFolderChangeData.tab)
strCommand = "Go " & chr(34) & path & chr(34) & " NEWTAB"
logMsg(strCommand)
objCmd.RunCommand(strCommand)

Set objCmd = Nothing
OnBeforeFolderChange = True

End Function

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

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

End Sub[/code]
I or someone else who continues should post a finished script in the Scripting forum :slight_smile:... Work to do here would be to provide a ScriptConfig array to allow the user to add folders/folderpaths to a list in Prefs to open in a newtab. Right now, this test script opens EVERY folder in a newtab. Test with caution...