GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Support for dynamic column settings

#1

Hello Dopus'ers,

I would like to suggest an extension to the ScriptColumn feature. Being able to dynamically assign configuration values.

There are a few ScriptColumn that have been created that contain configuration on a per column basis. For example one of the many regexp columns regex columns reloaded, and custom-text. These scrips are all configurable in that extra custom columns can be added by editing the script config, often stored in the script file.

There are also some columns like the newest file, and newest file with filtering. Where there are many similar columns with slightly different settings.

Adding a new type of ScriptColumn that supported assigning configuration values would make these easier to create in a flexible way and easier to use. The column could be configured via customised Script Dialogs.

For example the user selects the newest file column. They display the columns script dialog, where they select recursive and some other setting, like a filter and how to output the results.

Or I might add two regexp columns and similarly configure them as needed. Displaying columns script dialog and entering the regexp and other settings.

Thoughts?

Using Custom Dialogs
#2

I think configuring script columns at the moment you turn them on (vs configuring which columns the script provides in advance, e.g. from the script's Config dialog) would make things complicated for both users and script authors.

It needs to be possible to turn columns on and off (without a dialog appearing every time) via commands. The commands would need a way to pass the custom configuration to the script in text format, and the user and script would need a way to get the text version of the configuration.

When config wasn't passed, I think this idea would end up triggering a dialog in unexpected places.

You might be able to make a script that has a toolbar button (or menu item etc.) you can click to add new columns. That could show a custom dialog, then save the details of the column, add the column to Opus (via Script.InitColumns), and even turn the column on as the last step. I think that would be a better way to do what you're looking for.

#3

Having a button to configure the columns as you describe is nice plan. Will take look at the CustomDialog functionality see what I can get going.

That style of dialog might also be useful for other scrips like the external compare tools script. Where there is large blocks of config that the user might like to edit or extend.

Thanks for the input.

#4

I had some success getting this to work.
I adapted a script that supports custom xml-and-xpath-columns. I moved the column config from being hard coded in the script to a script-defined variable. I would have preferred using the ScriptConfig but I think this is readonly to the script?

This dialog configures the columns, it is triggered by a button. The Apply Changes button saves the changes (to a variable) and triggers a refresh of the ** custom column**. This makes testing column configurations pretty easy.

This button displays the above dialog.

<?xml version="1.0"?>
<button backcol="none" display="both" textcol="none">
	<label>Xml</label>
	<icon1>#XmlColumns:XmlBlue</icon1>
	<function type="normal">
		<instruction>XmlColumnsConfigure</instruction>
	</function>
</button>

XmlColumns.osp (12.3 KB)

If you would like to test try this xml and the.

  • xpath .//*[1]
  • will match the amount
  • xpath .//*[2]
  • will match the date
<?xml version="1.0" encoding="UTF-8"?>
<note>
  <amount>50</amount>
  <date>2017-12-13</date>
</note>

feedback welcome.

Need help with JSON serialization in the VBScript
#5

Pretty good from my point of view. o)

A little drawback is the lose coupling between a button somewhere and a mystic script variable.
Well, the script var is not that mystic anymore once you know about it, but some people might wonder where their configuration is stored. It would be nice though, if a script could write into its own (or others) ScriptConfig items.

To get some tighter relation between script and button:
The external toolbar button which brings up your custom dialog to edit the columns could also be launched by the "i" icon in the scripts section of the prefs (OnAbout() functionality), but the "i" is actually still not the right place. A custom "gear" icon in the script prefs to trigger custom config dialogs would be best. o)

#6

To a user, it won't matter if the config is stored in a ScriptConfig object or a Var object. It's all mystic behind-the-scenes details that they won't even be aware of.

Allowing scripts to display their own dialogs in place of the generic script config dialog might make sense, though. I think we'd need to see more than one script that could benefit from it for it to be worth implementing, but it's something we should keep in mind and is certainly a good idea.

#7

I agree, which is why i created this global-variable-management-dialog. I will need to include some instructions as to where it is. Maybe add the name of the var as ScriptConfig.

Agreed. Also I wanted to allow someone to edit the config without the dialog if they wanted. But the Dialog works so well I am not sure its needed, I would not bother.

@Leo, is right it does not matter to the user. Still having all the config in the same place as the other config makes sense, if someone goes looking for it.

This dialog does not edit all the config, only what is specific to the columns. I think I would rather allow the dialog to display from the default config, not instead of.

I have ideas for a couple more :slight_smile:

#8

Building on an older script, a similar dialog for creating regexp columns.
Its still a work in progress, but gives an idea.

feedback welcome.

Button for dialog

<?xml version="1.0"?>
<button backcol="none" display="both" textcol="none">
	<label>RegExp </label>
	<tip>Manage RegExp Columns</tip>
	<icon1>#RegExpColumns:RegExpBlue</icon1>
	<function type="normal">
		<instruction>RegExpColumnsConfigure</instruction>
	</function>
</button>

RegExpColumns.osp (31.6 KB)