When starting out in single display mode (works fine if already in dual display mode), running from an OnAfterFolderChange script:
strCommand = "Go " & vbQuote & strPath2 & vbQuote & " NEWTAB=findexisting OPENINDUAL NOSCRIPT"
The command behaves as expected (lister is switched to dual display with a new tab showing the path in strPath2), but a subsequent test of:
objCmd.Results.newtabs.count
...is set to 0 still.
Create a C:\temp and C:\temp2 folder... open C:\temp while in single display mode, no tablink. Do it again with the lister already in dual display, tablink is ok.
[code]Option Explicit
' Called by Directory Opus to initialize the script
Function OnInit(ByRef initData)
DOpus.Output("Initializing...")
' Provide basic information about the Script
initData.name = "OnAfterFolderChange_vbtest"
initData.desc = "Adds 'OnAfterFolderChange_vbtest' and 'OnCloseTab' event handlers 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_BSTR
initData.config.strScriptVT_BSTR = "VT_BSTR"
'////////////////////////////////////////////////
' Create a ScriptConfig property of type VT_I4
initData.config.iScriptVT_I4 = 255
'////////////////////////////////////////////////
' Create a ScriptConfig property of type VT_BOOL
initData.config.bScriptVT_BOOL = False
'////////////////////////////////////////////////
' Create a ScriptConfig property of type VT_VECTOR / VB TypeName() will return type : Variant
initData.config.objScriptVT_VECTOR = DOpus.NewVector("")
End Function
' Called before a folder is opened
Function OnAfterFolderChange(ByRef afterFolderChangeData)
Dim message
message = ""
Const vbQuote = """"
Dim STRING
STRING = "VT_BSTR"
logMsg("")
logMsg("------------Begin------------")
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////
' Do 'other' stuff...
'////////////////////////////////////////////////
' Command stuff
Dim objCmd, strPath, strPath1, strPath2, strCommand
Set objCmd = DOpus.CreateCommand
strPath = afterFolderChangeData.tab.path
strPath1 = "C:\temp"
strPath2 = "C:\temp2"
logMsg("User opening path: " & strPath)
If (DOpus.FSUtil.ComparePath(strPath, strPath1)) Then
objCmd.SetSourceTab(afterFolderChangeData.tab)
strCommand = "Go " & vbQuote & strPath2 & vbQuote & " NEWTAB=findexisting OPENINDUAL NOSCRIPT"
logMsg(strCommand)
objCmd.RunCommand(strCommand)
If (objCmd.Results.newtabs.count > 0) Then
logMsg("New tabs were opened: " & objCmd.Results.newtabs.count)
strCommand = "Go TABLINK=" & afterFolderChangeData.tab & "," & objCmd.Results.newtabs(0) & ",slave"
logMsg(strCommand)
objCmd.RunCommand(strCommand)
End If
End If
Set objCmd = Nothing
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
logMsg("")
logMsg("------------End------------" & vbCrLf)
End Function
Function OnCloseTab(ByRef closeTabData)
Dim objCmd
Set objCmd = DOpus.CreateCommand
If (closeTabData.tab.linktab = 0) Then
logMsg("No tab link: " & closeTabData.tab.linktab)
Else
logMsg("Tab linked: " & closeTabData.tab.linktab)
'objCmd.SetSourceTab(closeTabData.tab.linktab)
'objCmd.RunCommand("Go TABCLOSE")
End If
Set objCmd = Nothing
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]