This is about the use case of running hand-written .dcf files using dopusrt.exe
, which is how I began implementing more complex voice commands.
<?xml version="1.0"?>
<button>
<function type="script">
<instruction>@script JScript</instruction>
<instruction><![CDATA[
function OnClick(clickData) {
// Having multiple JScript lines in a single `<instruction>`
// element already works (just not in a CDATA node), also with
// `Command.AddLine()`, which is very useful to get correct
// line numbers in errors, because `AddLine("")` gives an
// error and there are other line-number-related bugs.
// However, when writing the JScript directly in the .dcf
// file, you currently have to escape `&`, `<`, and `>`, which
// is quite ugly and easy to forget:
var foo = true;
var bar = false;
if (foo && bar) {}
var a = 10;
var b = 20;
if (a < b) {}
if (a >= b) {}
// With support for CDATA nodes inside `<instruction>`
// elements as demonstrated here, which should be very easy to
// add, you wouldn't need to do this escaping.
}
]]></instruction>
</function>
</button>