VivoQuant 6.5.0
Loading...
Searching...
No Matches
Running Scripts from the Command Line

VivoQuant can run a script as soon as it starts:

vivoquant --script myscript.vqs

On macOS, run the executable inside the application bundle, VivoQuant.app/Contents/MacOS/VivoQuant. --help lists all command line options.

A session started with --script is not interactive: VivoQuant skips its startup dialogs, and isInteractive() returns false, so don't count on a user being there to answer dialogs. To close VivoQuant when the script is done, call quit(); it doesn't ask for confirmation in a non-interactive session.

Passing Arguments to a Script

Pass a comma-separated list with --script-args. The script gets the global array scriptArgs, holding one string per argument:

vivoquant --script myscript.vqs --script-args "input.dcm,results,42"
// scriptArgs only exists when VivoQuant was started with --script-args
var args = (typeof scriptArgs !== "undefined") ? scriptArgs : [];
VQ.debug(args[0]); // writes "input.dcm" to the VQ log
var count = parseInt(args[2]); // arguments are always strings
  • Arguments are split at commas only, so an argument can't contain a comma. Spaces are kept: --script-args "first arg,second arg" gives ["first arg", "second arg"]. Put the value in quotes when it contains spaces.
  • scriptArgs is already an array: index it directly rather than converting it to a string and splitting that again.
  • --script-args needs --script.

Named Arguments

For more than a couple of arguments, key=value pairs are easier to keep straight than positions:

// vivoquant --script myscript.vqs --script-args "input=C:/data/scan.dcm,threshold=0.5"
var opts = {};
var args = (typeof scriptArgs !== "undefined") ? scriptArgs : [];
for (var i = 0; i < args.length; ++i) {
var eq = args[i].indexOf("=");
if (eq > 0) {
opts[args[i].substring(0, eq)] = args[i].substring(eq + 1);
}
}
VQ.debug(opts.input); // writes "C:/data/scan.dcm" to the VQ log