Whilst developing a script that operates on both sides of a dual lister I came across "interesting" behaviour. In an attempt to understand/demonstrate what was happening I wrote a JavaScript command that sends two sequential Select commands to the right pane and then the same two commands to the left pane. The following sequence of screen grabs shows what happens when the command is run in various modes.
In all examples, the first command sent to both right and left panes is Select FIRST TYPE=files.
In "invert" examples the second command is Select INVERT and in non-invert examples the command is SELECT SIMILAR.
In "func" examples the func.command object is used and in non-func examples a DOpus.command object is used.
The starting point for each test is a single tab in a single lister using what is effectively a vanilla configuration.
The first test (SIMILAR) does what I expect in the right pane and apparently does nothing in the left pane.
The test script is attached as is the test command launch toolbar. In addition to the questions raised by the difference between func and DOpus command behaviour, and INVERT vs SIMILAR, I should also note that when I run the same tests using my regular configuration instead of the vanilla configuration used here, the outcomes are equally erratic but not the same as described above. One thing at a time.....
The files are being selected correctly but then those in the source tab are deselected almost immediately. This is kind of by design (the Command object is designed to deselect the files it uses unless you set its deselect property to true), however it's also a bug in that in this case, the Command object isn't actually using any files itself.
We'll fix the bug in the next update. In the mean time, you can work around it by adding the following two lines to the script:
Thanks @Jon, that certainly improves things for a DOpus.command object but not for a func.command object. Hopefully I have implemented your changes correctly.
With your changes in place and DESELECTNOMATCH added to the initial Select FIRST command, and with the same folder open in both sides and nothing originally selected:
If I execute qnd, qnd invert and qnd again in sequence, everything works as expected . However, when I do the same with qnd func, qnd func invert and qnd func in sequence, results are as shown below the updated test command.
The difference is due to the fact that the Command object that you get from func.command has its view of the file selection locked in when its created, whereas the one you get from DOpus.command doesn't.
Select SIMILAR needs selected files to work on, but in this instance the Command object "knows" it doesn't have any.
The solution is to update the Command object's file list after running the Select FIRST command.
cmdobj.runcommand(cmdstr1);
// update for dest tab
thislister.desttab.Update();
cmdobj.SetFiles(thislister.desttab.selected);
....
cmdobj.runcommand(cmdstr1);
// update for source tab
thislister.activetab.Update();
cmdobj.SetFiles(thislister.activetab.selected);