Option Explicit ' Lock states: ' 0=lock off; 3=lock, allow only navigate to sub folders ' ----------------------------------- ' Event handler before folder change ' ----------------------------------- Function OnInit(ByRef oInitData) Dim oCmd DOpus.Output("Initializing...") ' Provide basic information about the Script oInitData.name = "ScriptCommand_LockFolder" oInitData.desc = "Sets the LockTab state to Directory Opus." oInitData.copyright = "(c) 2014 BitStreamWorld" oInitData.version = "v1.0.0 (vbs)" oInitData.default_enable = True ' Create new ScriptCommand set oCmd = oInitData.AddCommand oCmd.name = "LockFolderChangesOnlyDown" oCmd.method = "OnLockFolderChangesOnlyDown" oCmd.desc = oInitData.desc oCmd.label = "Lock folder allow changes only go folder down" oCmd.template = "LOCKSTATE/N" ' Set DEBUG flag below to true in order to enable logging messages to the Opus Output Window oInitData.config.DEBUG = True End Function ' ----------------------------------- ' Event handler to lock a tab folder ' ----------------------------------- Function OnLockFolderChangesOnlyDown(oFuncData) Dim iLockState Dim oCurrentTab logMsg("OnLockFolderChangesOnlyDown") iLockState = 0 If oFuncData.func.args.got_arg.lockstate Then ' lock state of tab given by parameter iLockState = oFuncData.func.args.lockstate ' set to the current lock state which is set by a button End If logMsg("lock state set to " + CStr(iLockState)) ' unlock or lock to the current path of the tab set oCurrentTab = oFuncData.func.sourcetab SetTabLockStateToCurrentPath oCurrentTab, iLockState End Function ' ----------------------------- ' Event handler when tab opens ' ----------------------------- Function OnOpenTab(oOpenTabData) 'init to not lock SetTabLockState oOpenTabData.tab, 0 SetTabLockPath oOpenTabData.tab, "" End Function ' ---------------------------- ' Set and get tab lock states ' ---------------------------- Sub SetTabLockStateToCurrentPath(ByRef oCurrentTab, iLockState) SetTabLockState oCurrentTab, iLockState SetTabLockPath oCurrentTab, oCurrentTab.path End Sub Sub SetTabLockState(ByRef oCurrentTab, iLockState) If IsNull(oCurrentTab) Then Exit Sub End If oCurrentTab.Vars.Set "LockState", iLockState End Sub Sub SetTabLockPath(ByRef oCurrentTab, sLockPath) If IsNull(oCurrentTab) Then Exit Sub End If oCurrentTab.Vars.Set "LockPath", sLockPath End Sub '------------------------------------------------------------------------------------------------------------ ' Subroutine to allow toggling of the global VT_BOOL variable to control whether logging is performed or not '------------------------------------------------------------------------------------------------------------ Sub logMsg(sMessage) If (Script.config.DEBUG) Then DOpus.Output(sMessage) End If End Sub