How to Debug a Script

Fixing Script Errors

The syntax colorization within the Inquisit editor can be helpful for detecting some problems, such as misspelled commands, missing quotation marks, or missing close tags.

A deeper level of error detection happens when the script is parsed. The parse phase can be triggered by selecting the Validate Script command, or by running the entire script or a particular element. During the parsing phase, Inquisit may detect a variety of errors, including malformed syntax, references to elements that have not been defined, links to media files or included scripts that it can not locate or load, or file access errors.

Inquisit will report any script errors detected during the parse phase in the Error window at the bottom of the screen. Each error reports the specific element and attribute where the error occured, along with a descriptive message. If you double-click an error, the Inquisit editor will jump to the location of the attribute and element in the script where the problem lies. Many errors can be fixed by examing the problematic command, reading the descriptive error message, and making the appropriate changes.

Help on Syntax

For additional information about a given command, place the cursor in the element that caused the error and press the F1 key to open the reference topic for the element.

The Debugger Watch Window

The Debugger Watch Window halts execution of the script and shows you the current values of every propery in the script at that point in time. This can be a useful advanced tool for debugging expressions that reference various property values. For example, if you have an expression in the script comparing two property values, and the result of the comparison is not what you expect, you can use the Debugger Watch Window to see what those values actually are as the script is running at the point when the comparison is being made.

There are two ways to open the Debugger Watch Window. You can open it using the following keyboard shortcut while the script is running.

Press Ctrl+D

You can also call the script.debugbreak() function if you wish to see property values at a particular point in the script logic.

Test Monkey

The Test Monkey provides a way to quickly produce sample data from your script. You can then analyze the data file to check whether the structure of the experiment is as expected. For example, you can load the data into Excel and build pivot tables to check that blocks are run in the expected order, items are randomly selected at the expected counts, the correct number of trials are run, and that other structural constraints in the experiment are met.

More information on the Test Monkey is available in the How to Test an Experiment help topic