Running Sequences of Inquisit Scripts and Other Applications

A single experiment does not necessarily fit into a single Inquisit script. In many cases it may be necessary to collect data using a combination of different Inquisit scripts, or even a combination of different data collection programs. Ideally, the different scripts and programs would run as a single, seamless sequence of tasks requiring no manual intervention from the researcher. This article discusses approaches to achieve this.

Using the Inquisit Batch Element

The Inquisit language provides a simple facility for stringing together multiple scripts into a single data collection session, the batch element. The batch element allows you to specify a list of script files to run in order.

<batch>
/ file="SART.iqx"
/ file="WCST.iqx"
/ file="snowshoe.iqx"
</batch>

The batch element must be defined in its own seperate file. To run the batch element, simply open the script containing the batch element definition in Inquisit and run it as you would run any other script.

This is a very simple approach, but it is also somewhat limited. The batch provides no way to launch other programs besides Inquisit, and it does not allow you to counterbalance the order in which the scripts are run. For that, we can rely on Windows batch files.

Using Windows Batch Files

Most researchers assume that running a sequence of data collection programs together requires the ability of the data collection software to launch other software applications. The applications can thus be daisy-chained together, with each application launching the next application in the sequence. In fact, this capability isn't really necessary at all. Everything you need to run batches of applications in sequence is built directly into the Windows operating system.

Those of you who remember the days of Microsoft DOS are probably familiar with batch files. Batch files are simple text files, usually named with the "*.bat" file extension, that contain a series of shell commands. Shell commands can move, copy, and delete files and folders. They can search for files by name or that contain a particular string of text. They can format a hard drive. Most importantly for our purposes, however, they can launch applications.

Creating a batch file

Creating a batch file is simple:

  1. Click the Windows Start button in the lower left corner, and select "My Computer".
  2. Navigate to the C: hard drive by double clicking its icon.
  3. Open the "File" menu, select the "New" command, and then select "Text Document".
  4. Now, rename the text file you created to "millisecond.bat". Click "OK" when Windows asks you to confirm that the name change.
  5. Right click the millisecond.bat file and select the "Edit" command. This will open the file in the Notepad text editor.

Now we're ready to enter in some commands. For the sake of example, let's assume that our experiment consists of two Inquisit scripts called "SART.iqx" and "WCST.iqx". We'd like to run the "SART.iqx" script first, then have the subject play a game of Solitaire to serve as a distractor task before running the "WCST.iqx" scrip. To launch the "SART.iqx" Inquisit script, we use the same syntax that we would use to launch the script from the Windows command line shell (hence, the name "shell commands"). The Inquisit.exe program accepts 3 command line parameters that specify the script to run, the subject id, and the group id (see here for a list of supported commandline arguments). Thus, the first command in the batch file is the following:

"C:/Program Files\Millisecond Software\Inquisit 5\Inquisit.exe" "C:\Myscripts\SART.iqx" -s 23 - g 1

The first part of the command is the full path to the Inquisit executable file (yours may be different depending on where you installed Inquisit). The second part specifies the full path of the script to run. The third part is the subject number (more on this later). Now, on the second line of the file we'll add the command for launching the Windows Solitaire application, which changes our batch file to the following:

"C:\Program Files\Millisecond Software\Inquisit 5\Inquisit.exe" "C:\Myscripts\SART.iqx" -s 23 -g 1
"C:\Windows\System32\sol.exe"

Finally, we'll add a third line to the file to run the "WCST.iqx" Inquisit script.

"C:\Program Files\Millisecond Software\Inquisit 5\Inquisit.exe" "C:\Myscripts\SART.iqx" -s 23 -g 1
"C:\Windows\System32\sol.exe"
"C:\Program Files\Millisecond Software\Inquisit 5\Inquisit.exe" "C:\Myscripts\WCST.iqx" -s 23 -g 1

Our batch file is almost complete. We can run the file either by double clicking the file with the mouse, or by opening the Windows command line, moving to our desktop directory, and typing "millisecond.bat". The batch file first runs "SART.iqx". When that script is complete, it opens the Windows Solitaire application. When Solitaire is closed, it runs the "WCST.iqx" script in Inquisit. In both cases, it sets the subject number to "23".

Wait a minute, you may be thinking, won't this batch file set assign "23" to all of my subjects? The answer is yes. Obviously, that's not very useful as we'll need the ability to specify a unique subject number for each participant. Fortunately, this isn't difficult because Windows allows you to pass command line parameters to batch files as well. In our case, we'll want to pass the subject number to the batch file, and have it apply that number to both Inquisit scripts. We can do that by modifying the batch file as follows:

"C:\Program Files\Millisecond Software\Inquisit 5\Inquisit.exe" "C:\Myscripts\SART.iqx" -s %1 -g 1
"C:\Windows\System32\sol.exe"
"C:\Program Files\Millisecond Software\Inquisit 5\Inquisit.exe" "C:\Myscripts\WCST.iqx" -s %1 -g 1

All we've done is replaced "23" with "%1". Windows will substitute the value of the first command line parameter passed to the batch file wherever it see's a "%1". (All occurences of "%2" would be replaced by the second parameter, "%3" by the third parameter, and so forth).

We've now got a batch file that will run the three pieces of our experiment in sequence, but what if we want to counterbalance the order of our Inquisit scripts? No problem, we'll just add some additional logic to our batch file. Our batch file is going to need a second command line parameter that tells us the order to run the Inquisit's scripts and an "IF" statement to select the correct order.

IF "%2" == "A" (
"C:\Program Files\Millisecond Software\Inquisit 5\Inquisit.exe" "C:\Myscripts\SART.iqx" -s %1 -g 1
"C:\Windows\System32\sol.exe"
"C:\Program Files\Millisecond Software\Inquisit 5\Inquisit.exe" "C:\Myscripts\WCST.iqx" -s %1 -g 1
) 
IF "%2" == "B" (
"C:\Program Files\Millisecond Software\Inquisit 5\Inquisit.exe" "C:\Myscripts\WCST.iqx" -s %1 -g 1
"C:\Windows\System32\sol.exe"
"C:\Program Files\Millisecond Software\Inquisit 5\Inquisit.exe" "C:\Myscripts\SART.iqx" -s %1 -g 1
)

Now our batch file takes two command line paramters, the first is the subject number and the second (either "A" or B") indicates which order to run. If the second parameter is neither "A" or "B", neither condition is run.

Running the batch file

Our batch file is now finished, so let's take a look at how to run it. We can no longer double click the file to run it, because the file is expecting us to supply a subject number as a first parameter. Instead, we'll launch the batch file from the Windows command line shell. To open the command shell, do the following:

  1. Click the Windows Start button in the lower left corner of the screen.
  2. Select the "Run..." command.
  3. Enter "cmd" in the text input box, and click the "OK" button. This will open a command line console window.
  4. In the console window, type "cd c:\ " to navigate to the root folder of the C drive (if you are using a different drive, then switch the drive letter).
  5. To launch your batch file, type "millisecond.bat 99 A". Note that 99 is the value of the the subject number and A specifies the first counterbalancing condition. To run the second counterbalancing condition, you would type "millisecond.bat 99 B"

We now have a batch file that allows us to run multiple Inquisit scripts in counterbalanced order, as well as running a another software application, "Solitaire". To the participant, these different pieces will seamlessly flow together. Click here for the completed batch file.

Batch files are a powerful tool that can be used to automate many different aspects of data collection, including automatically backing up data files to another location when a session is complete, preprocessing data, or even logging off of Windows after a script is complete to prevent tampering (using the Windows "logoff.exe" program).