When working with JavaScript in QScripts and Rules, information can be shown in a message box for diagnostics. For example, the following code snippet can be used in a QScript to check to see if a variable called weight exists and, if it does not, aborts the script and has an error message pop up to the user:
if (data_file.getVariableByName("weight") == null)
alert("Data file does not contain a variable called 'weight'.");
You can also simply show messages in pop up windows without aborting the QScript or Rule using log(). The following prints the underlying value of Don’t know from a similar script:
log("Don't know in the age question has the value of " + dk_value);
Using log() to print the value of variables in your code is useful when troubleshooting JavaScript code.