Enhance set DUAL=On,remember

Switching from single to dual display with Set DUAL=ON,remember doesn't remember the left/right position of the active file display but always restores it to the left display. I'd suggest to enhance this to restore the paths to their original positions.

I never understood why the remember argument doesn't remember the position of source/destination. Some sort of dementia or a dogma that the natural home of the source has to be the left file display? :smiley:

However, I found a script that I was able to modify to my needs here: DO11 Scripting: Create Lister variables on OnClick function Many thanks to peperoni for providing the script.

I created three buttons from the script that toggles dual/single mode. The first opens the viewerpane in single mode, the second opens the metapane and the third only toggles dual/single mode closing both metapane and viewerpane if necessary. The buttons works fine together because they all use the same variable DUALSWAP to swap left/right if necessary.
It's possible to e.g. click the ToggleViewpane Button to have the Viewerpane in single mode and then click the ToggleMetapane button to additionally show/hide the metapane. Clicking the ToggleViewpane button again toggles back to dual mode closing both panes.

ToggleViewpane
<?xml version="1.0"?> <button backcol="none" display="both" textcol="none"> <label>ToggleViewpane</label> <icon1>#viewerpane</icon1> <function type="script"> <instruction>@language vbscript</instruction> <instruction /> <instruction>Function OnClick(ByRef ClickData)</instruction> <instruction> If (ClickData.Func.Command.IsSet(&quot;VIEWPANE=Off&quot;)) Then</instruction> <instruction> Call Restore(ClickData)</instruction> <instruction> Else</instruction> <instruction> Call Save(ClickData)</instruction> <instruction> End If</instruction> <instruction>End Function</instruction> <instruction /> <instruction>Sub Save(ClickData)</instruction> <instruction> If (ClickData.Func.Command.IsSet(&quot;DUAL=Off&quot;)) Then</instruction> <instruction> DOpus.vars.Set &quot;VIEWPANEDUAL&quot;, false</instruction> <instruction> Else</instruction> <instruction> DOpus.vars.Set &quot;VIEWPANEDUAL&quot;, true</instruction> <instruction> If ClickData.Func.sourcetab.right Then</instruction> <instruction> DOpus.vars.Set &quot;DUALSWAP&quot;, true</instruction> <instruction> Else</instruction> <instruction> DOpus.vars.Set &quot;DUALSWAP&quot;, false</instruction> <instruction> End If</instruction> <instruction> ClickData.Func.Command.RunCommand(&quot;SET Dual=Remember,Toggle&quot;)</instruction> <instruction> End If</instruction> <instruction> ClickData.Func.Command.RunCommand(&quot;Set VIEWPANE=On&quot;)</instruction> <instruction>End Sub</instruction> <instruction /> <instruction>Sub Restore(ClickData)</instruction> <instruction> Dim dual, swap</instruction> <instruction> dual = false</instruction> <instruction> swap = false</instruction> <instruction> ClickData.Func.Command.RunCommand(&quot;Set VIEWPANE=Off&quot;)</instruction> <instruction> If DOpus.vars.Exists(&quot;VIEWPANEDUAL&quot;) Then</instruction> <instruction> dual = DOpus.vars.Get(&quot;VIEWPANEDUAL&quot;)</instruction> <instruction> End If</instruction> <instruction> If (ClickData.Func.Command.IsSet(&quot;DUAL=Off&quot;)) and dual Then</instruction> <instruction> ClickData.Func.Command.RunCommand(&quot;Set METAPANE=Off&quot;)</instruction> <instruction> ClickData.Func.Command.RunCommand(&quot;SET Dual=Remember,Toggle&quot;)</instruction> <instruction> If DOpus.vars.Exists(&quot;DUALSWAP&quot;) Then</instruction> <instruction> swap = DOpus.vars.Get(&quot;DUALSWAP&quot;)</instruction> <instruction> End If</instruction> <instruction> If swap Then</instruction> <instruction> ClickData.Func.Command.RunCommand(&quot;Go SWAP&quot;)</instruction> <instruction> ClickData.Func.Command.RunCommand(&quot;Set FOCUS=Right &quot;)</instruction> <instruction> End If</instruction> <instruction> End If</instruction> <instruction>End Sub</instruction> </function> </button>ToggleMetapane<?xml version="1.0"?> <button backcol="none" display="both" textcol="none"> <label>ToggleMetapane</label> <icon1>#metapane</icon1> <function type="script"> <instruction>@language vbscript</instruction> <instruction /> <instruction>Function OnClick(ByRef ClickData)</instruction> <instruction> If (ClickData.Func.Command.IsSet(&quot;METAPANE=Off&quot;)) Then</instruction> <instruction> Call Restore(ClickData)</instruction> <instruction> Else</instruction> <instruction> Call Save(ClickData)</instruction> <instruction> End If</instruction> <instruction>End Function</instruction> <instruction /> <instruction>Sub Save(ClickData)</instruction> <instruction> If (ClickData.Func.Command.IsSet(&quot;DUAL=Off&quot;)) Then</instruction> <instruction> DOpus.vars.Set &quot;METAPANEDUAL&quot;, false</instruction> <instruction> Else</instruction> <instruction> DOpus.vars.Set &quot;METAPANEDUAL&quot;, true</instruction> <instruction> If ClickData.Func.sourcetab.right Then</instruction> <instruction> DOpus.vars.Set &quot;DUALSWAP&quot;, true</instruction> <instruction> Else</instruction> <instruction> DOpus.vars.Set &quot;DUALSWAP&quot;, false</instruction> <instruction> End If</instruction> <instruction> ClickData.Func.Command.RunCommand(&quot;SET Dual=Remember,Toggle&quot;)</instruction> <instruction> End If</instruction> <instruction> ClickData.Func.Command.RunCommand(&quot;Set METAPANE=On&quot;)</instruction> <instruction>End Sub</instruction> <instruction /> <instruction>Sub Restore(ClickData)</instruction> <instruction> Dim dual, swap</instruction> <instruction> dual = false</instruction> <instruction> swap = false</instruction> <instruction> ClickData.Func.Command.RunCommand(&quot;Set METAPANE=Off&quot;)</instruction> <instruction> If DOpus.vars.Exists(&quot;METAPANEDUAL&quot;) Then</instruction> <instruction> dual = DOpus.vars.Get(&quot;METAPANEDUAL&quot;)</instruction> <instruction> End If</instruction> <instruction> If (ClickData.Func.Command.IsSet(&quot;DUAL=Off&quot;)) and dual Then</instruction> <instruction> ClickData.Func.Command.RunCommand(&quot;SET Dual=Remember,Toggle&quot;)</instruction> <instruction> ClickData.Func.Command.RunCommand(&quot;Set VIEWPANE=Off&quot;)</instruction> <instruction> If DOpus.vars.Exists(&quot;DUALSWAP&quot;) Then</instruction> <instruction> swap = DOpus.vars.Get(&quot;DUALSWAP&quot;)</instruction> <instruction> End If</instruction> <instruction> If swap Then</instruction> <instruction> ClickData.Func.Command.RunCommand(&quot;Go SWAP&quot;)</instruction> <instruction> ClickData.Func.Command.RunCommand(&quot;Set FOCUS=Right &quot;)</instruction> <instruction> End If</instruction> <instruction> End If</instruction> <instruction>End Sub</instruction> </function> </button>ToggleDual<?xml version="1.0"?> <button backcol="none" display="both" textcol="none"> <label>Toggledual</label> <icon1>#dualdisplay</icon1> <function type="script"> <instruction>@language vbscript</instruction> <instruction /> <instruction>Function OnClick(ByRef ClickData)</instruction> <instruction> If (ClickData.Func.Command.IsSet(&quot;DUAL=On&quot;)) Then</instruction> <instruction> Call Save(ClickData)</instruction> <instruction> Else</instruction> <instruction> Call Restore(ClickData)</instruction> <instruction> End If</instruction> <instruction>End Function</instruction> <instruction /> <instruction>Sub Save(ClickData)</instruction> <instruction> If ClickData.Func.sourcetab.right Then</instruction> <instruction> DOpus.vars.Set &quot;DUALSWAP&quot;, true</instruction> <instruction> Else</instruction> <instruction> DOpus.vars.Set &quot;DUALSWAP&quot;, false</instruction> <instruction> End If</instruction> <instruction> ClickData.Func.Command.RunCommand(&quot;SET Dual=Remember,Toggle&quot;)</instruction> <instruction>End Sub</instruction> <instruction /> <instruction>Sub Restore(ClickData)</instruction> <instruction> Dim swap</instruction> <instruction> swap = false</instruction> <instruction> ClickData.Func.Command.RunCommand(&quot;Set VIEWPANE=Off&quot;)</instruction> <instruction> ClickData.Func.Command.RunCommand(&quot;Set METAPANE=Off&quot;)</instruction> <instruction> If DOpus.vars.Exists(&quot;DUALSWAP&quot;) Then</instruction> <instruction> swap = DOpus.vars.Get(&quot;DUALSWAP&quot;)</instruction> <instruction> End If</instruction> <instruction> If (ClickData.Func.Command.IsSet(&quot;DUAL=Off&quot;)) and swap Then</instruction> <instruction> ClickData.Func.Command.RunCommand(&quot;SET Dual=Remember,Toggle&quot;)</instruction> <instruction> ClickData.Func.Command.RunCommand(&quot;Go SWAP&quot;)</instruction> <instruction> ClickData.Func.Command.RunCommand(&quot;Set SOURCE=Right &quot;)</instruction> <instruction> Else</instruction> <instruction> ClickData.Func.Command.RunCommand(&quot;SET Dual=Remember,Toggle&quot;)</instruction> <instruction> End If</instruction> <instruction>End Sub</instruction> </function> </button>I'm sure this can be done better e.g. with an event triggered script that sets DUALSWAP=true whenever I toggle from dual to single and the source was at the right file display so that a user command can use the variable to do the swap. I noticed a somewhat nervous flicker when the swap happens which might be caused by the set dual=toggle,remember command first opening the path in the left display and afterwards swapping it to the right. I tried to avoid this by saving left and right paths into variables that can be used with the Go command. That was also working but didn't really reduce the flicker and looses the file selection.

I didn't dare to provide these buttons in the scripting area because I'm not able to write scripts by myself and the code may be somewhat bad but it's working fine for me.
Perhaps someone (like Steje :wink: ) would like to optimize the scripts or provide a better solution.

You mean, when using Set Dual=toggle,remember, & toggling back, that with about 50% odds the wrong side will be switched back on again? :smiley:

Just tried the first button, with the left pane active when switching the view pane on, but switching back will have the right pane activated. If i understood you right, that's not how it is supposed to work. :question: :neutral_face:

No, that's definitely not how it should work. I never saw this button doing the wrong thing. For me it always restores to left what has been left and to the right what has been right and correctly sets the focus to the source. Sorry, I can't imagine what causes it to do the swap when the source was at the left side for you. Could you please also try the other two buttons? For me they're always working reliable as intended.

Sorry, Kundal, but for example the ToggleDual button isn't working right. It will toggle the pane ok, but is messing up all tabs (5 on the left, 4 on the right). Obviously, as i can see from a quick check, this code
is "stealing" all but one tabs from the left, moving them to the right in a random manner. The remaining one on the left is identical with the one, that was originally the leftmost one, while the "would-be" active tab from the left
(my default lister loads with the focus on the right side) gets actually the active one on the right side. Thus, the original tab from the right side i started with, won't have the focus back, as expected.

I guess, this happens due to some completely different background on my machine, regarding tabs or other things. Perhaps the presence of locked tabs here on either sides causes it. Also the ToggleMetapane button is always switching
back to the right file display, regardless which side was active. But besides of that, codes #1 & #2 work.

Weird. I can't reproduce what you see. All 3 Buttons are working absolutely reliable for me even with several (locked) tabs.

I can't think of anything else, that could interfere with the code. Folder formats shouldn't matter, i start the buttons directly per mouse from the toolbar, so no shortcut thing could cause it.
While the first two could have a trivial reason, i wonder what is going on with the third code. As i switch back, i can see additional tabs populate on the right side, as if the tab's "move" command
was triggered.

I just tried something else. When i use ToggleDual in my test environment (that's the default lister i'm using), almost all tabs from the left go to the right. So i have only 1 tab left on the left side,
& 8 on the right side. But when i toggle this command on & back, the result is having an empty tab on the left, & the tab, that previously was the mostleft tab on the left side, is getting the only
tab that's left over on the right side. :smiley:

To clarify: what i've described is what happens, when i toggle it a second time. Btw, after that second thing i had some crash.

Also interesting: when i start with the focus on the left, no tab-shuffling appears. All tabs stay, where they are. But the focus changes to the right, as in the previous examples.
If i switch over to the right, than that happens, what i described above. Maybe the crash dumps could give some information? Where can i send them?

[quote]Where can i send them?[/quote]Not to me. Crash Dumps are only for Leo or Jon. :smiley:
If you want to analyze what causes the crazy effects you see I'd try with a virgin DOpus installation to see if it's something in your config or disable some tools like AutoHotkey or what else is running on your machine that could interfere with the scripts. There's nothing in the scripts itself I can think of that could make tabs moving around.

Ok, problem solved. It wasn't any ac'tivAid or Hot Keyboard weirdness (this time :wink: ), but as a matter of fact, must have been caused by some
of the new scripts.

As i test wise turned them off, all works like you've described it. But now you know, how to possibly reproduce the weird stuff i saw. :smiley:

Yeah, that fits perfectly to my other thread: DO11: Bad Script AddIn confuses DOpus. Script Addins seems to be really dangerous stuff. :smiley:

Yeah. First i deactivated the ahk & HKP stuff, then i must have remembered that thread. & i also don't know much about the usage of scripts, plus they also still are in an experimental
stage, so no wonder.

Depends; you can also see them as fun stuff. In the future, i imagine all those scripts doing the work for us, while we sit there watching in amazement. :smiley:

It's the OnBeforeFolderChange_OpenNewtab.osp script package that's not compatible with my buttons. I was able to reproduce your issues with that package in my Script AddIns folder.

Cool, then i can leave that off for now, & change all three commands to your enhanced versions, which all work now as intended. Thanks!

I'm glad you like my buttons and got them working.
Was a funny trip into crazy script confusion with really bad effects on DOpus.:grin:

If you have multiple scripts that do things on folder change you have to be careful about how they interact.

Yeah, that's what I meant with dangerous stuff. It's dangerous especially for scripting noobs like abr and me. I don't think that there's a bug in what we experienced here. It's completely clear that event-triggered scripts can clash even with normal button codes. I will be very restrained in the future with scripts that works on events that happens very often like OnFolderChange, OnActivateTab, OnSourceDestChange and such (unless I want to ask the mystical DOpus Oracle: Choose 6 out of 64 scripts and see what DOpus tells you about upcoming life events). :laughing:
Looking at the content of the Script AddIns folder should be added to FAQ's like General slowdown or instability investigation steps and others because crazy issues like this will happen more often to users with DO11.

True. I yet have to learn, when to have scripts activated, or how to use them exactly. It's all quite unclear to me at the moment. Maybe we could use some new command, to toggle all scripts off, without having to
open the preferences page.