Command: Open file using extensions or mime-types to choose program

In such cases (script requiring customization by the user to provide for instance path to certain executables), the best thing to do imo is to expose those settings so the user can modify them.

It's not much more work for you, but makes it way easier for other users, especially the ones not really into coding, since they don't have to parse your code in search for the approriate lines to modify, be aware of the need to escaoe backslashes in path, and so on.

You need to do one or two things :

  • In the OnInit function, you have to set/declare those settings using initData.config_desc. You can also provide a default value. Example below :
function OnInit(initData)
{
	initData.name = "YourScriptName";
	initData.version = "1.0";
	// (...)
	initData.min_version = "13.0";

	// settings & defaults
	initData.config_desc = DOpus.Create.Map();
	var option_name = "";

	option_name = "SomePath";
	initData.Config[option_name] = "C:\\Program Files\\SomeFolder\\SomeExecutable.exe";
	initData.config_desc(option_name) = "Full Path to SomeExecutable.exe";
 )
  • [Optional] Implement OnScriptConfigChange to handle user change (to check/validate new setting for instance). Example below :
function OnScriptConfigChange(configChangeData)
{
	var someExePath = Script.Config["SomePath"];

	var fsUtil = DOpus.FSUtil;
	if (!fsUtil.Exists(someExePath)) {
		DOpus.Output(">>ERROR : Unable to locate (" + someExePath + ")");
		return;
	}
	else
		DOpus.Output(">>OK : SomeExe found (" + someExePath + ")");
}

DOpus will remember the user settings once it has been changed by user.
To access the settings, one needs to go to the Scripts management window and click on the settings wheel that displays as soon as you provide a non empty initData.config_desc.

For a full example, see Keep PC awake until one specific process ends