Problems with SortBy, and a script question

Two related questions about sorting a file display by columns.

  1. SCRIPTS: The 'Column' page in the script section of the Help manual specifies how to get the sort order, the reversed-or-not-reversed, and the width. Is there any script way to set these properties (other than RunCommand), or are DOpus commands required?

  2. SORTBY: My reason for wanting to use a script is that the DOpus command Set SortBy is behaving in ways that I don't understand. My problems concern the first column in the string of columns. I will describe things as clearly as I can, but I suspect that they more unpredictable than this.

(a) Both Set SortBy=ext and Set SortBy=-ext sort the extension column in forward alphabetical order. In each case, I mouse-click to sort on the 'Name' column immediately before running the command.

(b) But if instead I click to sort on Name, then click twice on Extension to sort it in reverse, the Set SortBy=ext has no effect (and neither does Set SortBy=-ext).

(c) Change the command to Set SortBy=-ext,-attr.

  • This command works, reverse sorting both columns (after first clicking on Name).
  • If instead I click to sort on Name, then click once to sort on Extension, then I have to run the button twice to get the desired result. First time is wrong, with Extension sorted forwards, Attributes in reverse. Second time is correct, with both columns reverse sorted.
  • Change the command to Set SortBy=-ext,-attr,-path. Same two results.

I don't know whether my system is corrupt, or if I'm misunderstanding, but it all seems unintended, and you can see why I am trying to use a script to set the sort order and the reverse-or-not-reverse as well as get them.

See the SORTREVERSE argument.

Minus (-) before a column name is usually only used when you want to sort by multiple columns and only reverse some of them.

Thanks Leo. That answers case (a), although the anomaly is tricky to deal with when writing a RunCommand (and it's also not clear in the SortBy documentation). The situation described in case (b) must be another special case, but both cases can be handled together by dealing separately with single-column cases.

The situation in case (c), second star, means that in general two runs of the command are required, because the result depends on the previous situation. (I tested doubling the command in a DOpus button, and it works.) Is this really intended?


Also, is there a script Set property or method that I am missing? That would be far easier. I tried 'obvious' statements such as
oColumn.sort = 3 and oColumn.reverse = true
(after the usual enumeration), but they don't seem to work.

Scripts set sort mode by running the command, as you're already doing.

You should not need to run the command more than once. What command are you now using that has that problem?

Thanks for confirming the situation with scripts. I am never confident that I haven't missed something. Here are thegory details you asked for.

(A) For an example of a SortBy command that has to be run twice, take the button in case (c) with the command:
Set SortBy=-ext,-attr (that's case (c) above)

  1. Click on Name to sort by the Name column.
  2. Run the button — both are sorted reverse, as expected.
  3. Click on Extension to sort forward on Extension
  4. Run the button — Extension is sorted forward (unexpected), Attributes reverse.
  5. Run the button again — both are sorted reverse, as expected.
  6. Further runs don't change anything.

(B) But I now realise that it's more complicated than this. With the same button as before:

  1. Click on Name to sort by the Name column.
  2. Run the button — both are sorted reverse, as expected.
  3. Click on Extension to sort forward on Extension.
  4. This time, click on Extension again to sort reverse on Extension.
  5. Run the button — Extension is sorted reverse (expected), but Attributes is sorted forward (unexpected).
  6. Run the button again — now Extension is sorted forward (unexpected), but Attributes is sorted reverse (expected).
  7. Further runs don't change anything, so the sort is never correct.

(C) And a further twist with the same button:

  1. Click on Name twice to reverse sort by the Name column.
  2. Run the button — Extension is now sorted forward (unexpected), Attributes reverse (expected).
  3. . . .

It would be really tricky using such commands in a RunCommand.

UPDATE:
I have a partially written script that can output column.sort and column.reverse. If I run it after each step in (A), (B) and (C) above, the results here are most peculiar.

(A) At each step, what the script reports is the same as what I see on the screen.

(B) The script reports diverge from what is on the screen from Step 4 onwards.
4. The script reports that Extension is still sorted forward.
5. The script reports that Extension is sorted forward and Attributes is sorted reverse.
6. The script reports that both columns is sorted reverse.

(C) Again the script report diverges from the screen.

  1. The script reports that Name is still sorted forwards after the second click.
  2. The script reports that both columns are sorted reverse.

After a little more playing about, it seems that:

  • After clicking on a column, the script reports forward sorting, even when the column is clicked twice and the sort on the screen is clearly reverse. This is the same whatever column is involved.
  • If, however, a multi-sort is generated by holding Ctrl and clicking, including clicking twice on some columns, then the script always seems to agree with the screen, even when the first sort column is reverse.
    Something seems to be badly astray here.

Try Set SORTBY=ext,attr SORTREVERSE=On

Set SORTBY=ext,attr SORTREVERSE=On does indeed give the correct sort on the screen in every case that I have tried.

When I look at the sort with my script, however, it reports that both Extension and Attributes are sorted forward, so the script property column.reverse is reporting the wrong state. That makes it rather impossible to control the sort with a script.


That was, of course, a special case, because both sorts are reverse, so try Set SORTBY=ext,-attr

  1. Click on Name once (screen and script agree that Name is sorted forward).
  2. Click on Extension (screen and script agree that Extension is sorted forward).
  3. Click on Extension again (screen has Extension sorted reverse, but script reports it forward).
  4. Run the button (screen has Extension reverse and Attribute forward, Script reports Extension forward and Attributes reverse).
    Further button clicks don't affect anything. Thus the script is reporting the state that the command was supposed to create, but didn't.

I'll spare you further details. Things are not working as expected, and more alarmingly, the script is misreporting the state of the screen.

There are two different reverse states.

There's a global reverse state (controlled by SORTREVERSE). This reverses the overall order of the list.
Then there's a per-column reverse state (controlled by the - prefix) which reverses the sort order of each particular column.

The column.reverse property is reporting the per-column reverse state. The Format.reverse_sort property is what you need to test to see if SORTREVERSE is in effect.

  1. Thanks, jon. I've now displayed format.reverse_sort as well, and there is now no conflict between the sorting displayed on the screen and the sorting reported by the script.

  2. My earlier problems arose when the first column was to be sorted reverse. Following leo's remarks, the procedure seems to be:

  • If the first sort column is to be forward, add the switch SortReverse=Off.
  • If the first sort column is to be reverse, change the sign in front of each column and add the switch SortReverse=On.
  1. A further principle with double inverted commas seems to be that when there are spaces, one set should enclose the whole list of columns, rather than putting each column in its own inverted commas.

But there are still problems. For example, I have four columns headed 'Filter000', 'Filter 001', 'Filter 002' and 'Filter 003'. Whatever the initial state of the sorting (and independent of inverted commas):

Set Sortby=scp:ADSFiltersAndTags/Filter001,scp:ADSFiltersAndTags/Filter002 SortReverse=Off
sorts first on Filter000 instead of on Filter 001, and second on Filter 002.

Set Sortby=scp:ADSFiltersAndTags/Filter001,scp:ADSFiltersAndTags/Filter002,scp:ADSFiltersAndTags/Filter003 SortReverse=Off
sorts second on Filter000, and third on Filter 003, with no visible column marked as the first sort. I suspect that the first sort is on a script column from another addin, similar to the problem reported the post below.

I tried columns from the addon EmlEmailColumns and got similar results. This all looks like the same problem that I reported earlier of script columns becoming confused with each other — see Can the script addin system become corrupt?

What does Set COLUMNSTOGGLE=scp:ADSFiltersAndTags/Filter001 do, if anything? Does it toggle the Filter001 column?

What's in /dopusdata/ConfigFiles/scriptcolumns.oxc and scriptconfig.oxc?

Set COLUMNSTOGGLE=scp:ADSFiltersAndTags/Filter001 does indeed correctly toggle the Filter001 column.

By the way, I'm only having trouble with the SortBy command when there is more than one column in the sequence. The two example of failures in my previous post listed two and three columns, whereas
Set SortBy=scp:ADSFiltersAndTags/Filter001 SortReverse=Off
sorts on the Filter001 column, as it should.

Maybe the next step is to uninstall all addins, move the files away, and reinstall them one-by-one?


I've emailed the files scriptcolumns.oxc and scriptconfig.oxc because of error messages.

Is this still causing a problem in 12.0.6? I've been having a look today and can't reproduce any issues, but there were some fixes to do with sorting recently which could be the reason.

The scriptcolumns.oxc and scriptconfig.oxc both look fine, by the way.

My tests were done with the Custom Column - Newest File script and these two commands:

Set SORTBY="scp:Newest File Column/NewestFile,scp:Newest File Column/NewestFileDate,scp" SortReverse=Off
Set SORTBY="scp:Newest File Column/NewestFile,scp:Newest File Column/NewestFileDate,scp:Newest File Column/NewestFileName" SortReverse=Off

Thanks, leo, for going back to this problem. I added all six columns from the script 'Newest File Column", and did some tests. ((Each time I sorted on 'Name' before issuing the command, not that this seemed to make any difference.)

  1. Your two example commands work perfectly on my system.

  2. I then added all six columns from the 'Newest File Column' script into your DOpus sort command, to give:

Set SORTBY="scp:Newest File Column/NewestFile,scp:Newest File Column/NewestFileDate,scp:Newest File Column/NewestFileDateRec,scp:Newest File Column/NewestFileName,scp:Newest File Column/NewestFileNameRec,scp:Newest File Column/NewestFileRec" SortReverse=OffThe result is not correct. The little grey numerals at the top of the columns indicate that:
The 1st column is sorted as #1.
The 2nd column is sorted as #4.
The 3rd column is sorted as #5.
The 4th column has no indication of having been sorted.
The 5th column has no indication of having been sorted.
The 6th column is sorted as #6.

  1. I then changed the command so that it only sorted the first five columns of the 'Newest File Column' script. Still no good:
    The 1st column is sorted as #1.
    The 2nd column is sorted as #4.
    The 3rd column is sorted as #3.
    The 4th column has no indication of having been sorted.
    The 5th column is sorted as #5.

  2. I then changed the command so that it only sorted the first four columns. This time the sorting was correct, and of course the two commands from your post sort on three and on two columns.


  1. Before I tested these commands, I went back to my last two of my previous posts, and tested my two problematic commands again. The behaviour was exactly as before. I should add that since that post, my 64-bit Windows 7 Pro computer has gone to the wreckers, and I am working on a new 64-bit Windows 10 Pro computer from a different maker. I installed DOpus on it, then 'restored' my previous configuration. DOpus is now at V12.0.6.5998, and Windows and everything else is fully updated.

To avoid confusion, I'll quote the relevant detail from my second-last post above:

[quote]But there are still problems. For example, I have four columns headed 'Filter000', 'Filter 001', 'Filter 002' and 'Filter 003'. Whatever the initial state of the sorting (and independent of inverted commas):

Set Sortby=scp:ADSFiltersAndTags/Filter001,scp:ADSFiltersAndTags/Filter002 SortReverse=Off
sorts first on Filter000 instead of on Filter 001, and second on Filter 002.

Set Sortby=scp:ADSFiltersAndTags/Filter001,scp:ADSFiltersAndTags/Filter002,scp:ADSFiltersAndTags/Filter003 SortReverse=Off
sorts second on Filter000, and third on Filter 003, with no visible column marked as the first sort. I suspect that the first sort is on a script column from another addin, similar to the problem reported the post below.
[/quote]I added quite a few other script columns to see if I could catch some other stray column from another script that was being sorted, but I had no success with that.

Many thanks! With that I was able to find the bug and we'll have a fix in the next versions.

It turns out to only happen with quite specific combinations of script column names and the Set SORTBY command using multiple columns.

Leo, things have certainly changed.

THE GOOD NEWS: All the commands in my last post run correctly.

THE BAD NEWS: A new problem seems to have been introduced, in that sorting is now going wrong when the sorting has both script comumns and ordinary columns. I hope that you can reproduce the problem from this description. In the example below, I alsways start with the script sorted by Name.

  1. There is a problem with just two columns, one ordinary and one script:
    (a) With script + ordinary, the sorting seems correct:
    Set SortBy="scp:Newest File Column/NewestFile,ext" SortReverse=Off

(b) But with ordinary + script, nothing seems to happens:
Set SortBy="ext,scp:Newest File Column/NewestFile" SortReverse=Off

  1. There are similar problems with three columns whenever an ordinary column precedes a script column. There are many cases here, but the following three are probably enough:
    (a) Script + script + ordinary seems to work:
    Set SortBy="scp:Newest File Column/NewestFile,scp:Newest File Column/NewestFileDate,ext" SortReverse=Off

(b) Script + ordinary + script seems to sort only on the first of the script columns, and to ignore the other two:
Set SortBy="scp:Newest File Column/NewestFile,ext,scp:Newest File Column/NewestFileDate" SortReverse=Off

(c) Ordinary + script + script seems to do do nothing at all:
Set SortBy="ext,scp:Newest File Column/NewestFile,scp:Newest File Column/NewestFileDate" SortReverse=Off

As you probably realise, I have a nice 'Universal Column Sorter' addin script here that I'm using to test things. I tried things out with columns from other scripts, with the same results. Apologies if all that is happening is that I am getting the syntax wrong.

Thank you. I've fixed that for 12.0.8.

leo, I reckon it's fixed in V12.0.8. I've tried many things, and I've found no errors. Congrats, and thank you.

Thanks for checking!