When using a command splitted in multiple lines as described in the manual, the parsing fails if there is no text after the command's name.
For example, with a test script.
test_multiline_args.opusscriptinstall (1011 Bytes)
(script's code)
function OnInit(initData) {
initData.name = "test_multiline_args";
initData.version = "1.0";
initData.copyright = "";
initData.desc = "";
initData.default_enable = true;
initData.min_version = "13.0";
}
// Called to add commands to Opus
function OnAddCommands(addCmdData) {
var cmd = addCmdData.AddCommand();
cmd.name = "test_multiline_args";
cmd.method = "Ontest_multiline_args";
cmd.desc = "";
cmd.label = "test_multiline_args";
cmd.template = "FILES/M,MULTI/K/R,FILTER/O,OTHERARGS/K/R,ANOTHERARGS/K/R";
cmd.hide = false;
cmd.icon = "script";
}
// Implement the test_multiline_args command
function Ontest_multiline_args(scriptCmdData) {
DOpus.ClearOutput();
DOpus.Output('cmdline : ' + scriptCmdData.cmdline);
DOpus.Output('OTHERARGS : ' + (scriptCmdData.func.args.got_arg.OTHERARGS ? scriptCmdData.func.args.OTHERARGS : 'nothing'));
DOpus.Output('FILTER : ' + (scriptCmdData.func.args.got_arg.FILTER ? scriptCmdData.func.args.FILTER : 'nothing'));
DOpus.Output('MULTI : ' + (scriptCmdData.func.args.got_arg.MULTI ? scriptCmdData.func.args.MULTI : 'nothing'));
DOpus.Output('ANOTHERARGS : ' + (scriptCmdData.func.args.got_arg.ANOTHERARGS ? scriptCmdData.func.args.ANOTHERARGS : 'nothing'));
}
Using:
test_multiline_args
[[
MULTI
some random value
]]
[[
OTHERARGS
another random value
]]
Gives:
But if instead you use:
test_multiline_args FILES
[[
MULTI
some random value
]]
[[
OTHERARGS
another random value
]]
It works if you include something on the same line as the command name—even random text.
test_multiline_args asdfdsf
[[
MULTI
some random value
]]
[[
OTHERARGS
another random value
]]