Debug commands are useful in tracking down problems, verifying values, or simply reviewing the execution of the program. The Debug object, when used with the Print method, is used to send information at runtime to the Debug tab of the Output window for examination following the run. For example, the following script could be used to write the value of the Stimulus attribute to the Debug tab in the Output window during each trial.
The script above will send the value of the Stimulus attribute per trial to the Debug tab in the Output window. After the run, the Debug output may be viewed by displaying the Output window within E-Studio. If the Output window is not displayed by default, select Output from the View menu. Then, in the Output window, select the Debug tab.
Debug.Print may also be used to monitor timing and response events. The following script uses Debug.Print to write the stimulus onset time and the participant’s response to the Output window.
The contents of the Debug tab may be copied to the clipboard by first selecting the lines of information in the Debug tag that are of interest and then right clicking in the Output window. Then, the Debug output may be pasted into Excel (or another application)hh to print it or use spreadsheet calculations to check the timing of events.
The Debug object is most appropriate during the development and testing of new programs. After an experiment has been fully tested, the Debug commands may be disabled by setting the Debug object’s Enabled property to “false” (i.e., Debug.Enabled = false). This allows the user to leave Debug commands in the script for future testing purposes, but to improve the efficiency of the program during data collection.
A final method of debugging involves the use of comments to indicate the purpose of certain sections of script. This method may be employed more often as a preventative measure than as a diagnostic tool, but can be of tremendous importance during debugging (especially if someone other than the author of the script is given the task of debugging). There is no standard style for adding comments, but in general they should be brief descriptions of the purpose of the segment of script. Many of the script examples used in this chapter make use of brief comments to summarize the purpose of the script for the reader. In E-Basic, comments are separated from script that is generated through the use of the apostrophe (‘) keyword or the Rem statement. Refer to the E-Prime Command Reference for further discussion of comments.