Dopus V11.7 has multiline config. Thanks for the update.
I was playing with this today when updating the Tab-Labelizer. I wanted to share my solution.
The Tab-Labelizer has some advanced config that is stored in script as a JSON object. Its to complex to put in to other config types. I wanted to allow the user to edit that confict without opening the script. I also wanted it to look nice, and not to have to store the default config in a string literal as that would require escaping values and make it hard to read.
This is the pattern I used (A cut down version of the code):
function OnInit(data) {
data.name = "test multiline script";
data.desc = "Display advanced JSON config in a multi line config.";
data.default_enable = true;
data.min_version = "11.7"
data.config_desc = DOpus.NewMap();
//Set ExtendedConfig default to be defaultExtendedConfig pretty printed.
data.config.ExtendedConfig = JSON.stringify(defaultExtendedConfig, undefined, 2).replace(/(\n)+/g,"\r\n");
data.config_desc("ExtendedConfig") = "Extended configuration, Be careful editing";
}
//Default values for extendedConfig
var defaultExtendedConfig = {
value1: true,
value2: "test",
AGroupOfSettings: {
enabled: true,
alist: [
"value1",
"value2",
"value3"
]
},
}
function OnMyCustomFunction(data) {
var extendedConfig = JSON.parse(Script.config.ExtendedConfig);
// Do stuff
}
Keen to hear any feedback, specifically regarding performance issues. I have a couple of other scripts that could use a similar set-up.