GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Numeric Sorting in script and non-script columns


From a very few experiments, it seems that whether or not numeric filename sorting is turned on:

  • Sorting in a non-script column other than Name --- for example Description --- is always non-numeric,
  • Sorting in a script column is always numeric,

First question: This seems odd behaviour --- is it intended?

Second question: How does one control this behaviour?

  • Is it possible:to turn on numeric sorting in a non-script column other than Name?
  • Is it possible:to turn off numeric sorting in a script column?

Third question: Am I misunderstanding things?


We've made a couple of changes for the next update:

  • Script columns will only use numeric sorting if it is turned on in Folder Options.
  • The ScriptColumn.type value can be set to nonumeric or noword (or both: nonumeric,noword) to prevent numeric and/or word sorting being applied to it, even when they are enabled in Folder Options.

Thanks Leo. What an impressive answer --- precisely the sort of thing that gives us all so much confidence in DOpus! I'll report back when the update comes out.


Thanks very much for the ability to specify the sorting method for a script column. I have got it working nicely, and I can also read off the way the column is sorted using format.numeric_name.

QUESTION: Once a column has already been created using the AddColumn method, is there a way to toggle the numeric sorting of it? I tried using the command format.numeric_name = false to set rather than get the variable, but it throws an error 'A method was called unexpectedly'. Obviously the AddColumn method is no longer available --- or is it?

The workaround would be to save all the parameters of the column, then destroy the column, then recreate it with the saved settings except for toggling the numeric parameter, which would all be rather tedious.


From the Script object:

If your script implements the Script.OnAddColumns event, you can call the InitColumns method at any time to reinitialize your columns. You may want to do this, for example, in response to the user modifying your script's configuration.


Thanks, Leo --- I was unaware of all this. But I must be misunderstanding something very basic here, because the command Script.InitColumns () with or without the round brackets throws the error:
Object doesn't support this property or method

I am working with a script addin. The function OnInit (initData) contains:

  • A single initData.AddCommand () called SetupSortConfigs
  • A single initData.AddColumn () called Substrings

The command Script.InitColumns () throws the error

  • when I place it within the function onSetupSortConfigs, whether or not the column is on, and
  • when I place it within the function onSubstrings.

Based on what Column - Custom Text and Regexp does:

function OnInit(initData)
    // DON'T add columns here.

function OnAddColumns(addColData)
    // Add columns here.

function OnScriptConfigChange(configChangeData)

I'd expect the call to be Script.InitColumns(); with the brackets, but it probably works whether or not they are used, due to a quirk of how ActiveScripting methods/properties are implemented. The example script I linked didn't use them, so I left it that way, but I'd add them in unless it causes problems.


Thanks very much, Leo, that was the clue --- add the script column in a separate function at the start. You worked out what I was doing wrong.

I've now got it working, I had to add a new variable var sType = "nonumeric" at the very top of the script before any functions, then set type = sType at the start within OnAddColumns. After that I could change the type by setting sType and calling Script.InitColumns (). A bit convoluted, but it seems to work

But two questions:

  1. There is a type = "nonumeric" to turn off numeric sorting, but there is no type = "numeric" to turn on numeric sorting, (If you do set type = "numeric", the script won't work.) If you set type to an empty string, it defaults to what the folder setting is.
    QUESTION: If the folder sorting is currently non-numeric, how do you set the column sorting to numeric?

  2. You can read the column type off, but it will be either "numeric" or "undefined", and if it is undefined, you then have to work off the folder setting using format.numeric_name.
    QUESTION: Is there a one-shot way to read the current numeric/nonumeric state?

  1. We'll add forcenumeric and forceword in the next beta so you can force them on as well as off.

  2. If you're aiming to make the script generate different data (e.g. padding with zeros) depending on the sort type, that's probably a bad idea. The settings in Folder Options can be changed after the column has been populated with data, triggering a re-sort of the existing data without calling the script again. You can't really make what you display conditional on Folder Options since those settings can change underneath you. (In fact, they could be changed by the user while the column is still populating, and you'd end up with half the data using one format and half using the other if you did that.)

    If the data you generate needs a particular sort mode, I would just force it on or off. You could have an option in the script's configuration to change the way the data is formatted and sorted instead, if needed.

  1. Thanks Leo. That surely completes the command.

  2. That's quite a tricky scenario that I hadn't thought of. Actually, I had no intention of changing the data at all, or of any automatic resort. I was just trying to construct a simple toggle button. Nevertheless, I agree that forcing one thing or the other is the safer way to go.

I'll report again after the next beta.