Script Task Events
E-Prime provides the ability to select user-written E-Basic script segments to be run as the Action of a Task Event. User-written script routines are entered into an E-Prime experiment via the User Script window (see SCRIPTING: User Script Window ).
User-written script routines must include one or two parameters, including “varname” As Context, and an optional second parameter. If a second parameter is specified, it is defined by the data type of the routine (i.e., Long, Integer, String, or Double). Refer to E-STUDIO: Configuring Task Events  for information pertaining to configuration of a parameter associated with a Script Task Event.
NOTE: Task events typically occur during time-critical portions of an experiment. For this reason, the actions that may be defined are restricted, and if the task event specified requires a significant amount of time (e.g., extensive script segments), timing within the experiment may be affected. To maintain accurate timing, task events should be brief, involving only essential actions, before returning to experiment execution.If extensive script is required in association with a task event, it is suggested that a Boolean value be set within the task event to trigger non-essential script at a later/non-critical time in the experiment outside of the task event, itself. Refer to E-STUDIO: Using Task Events  for further discussion concerning restrictions and timing associated with Task Events.
Define script routine
To specify a user-written script routine as the Action of a Task Event, first enter the script for the routine into the User Script window in the experiment. The image below illustrates entry of the EliminateOption routine in the User Script window within the ScriptTaskEvents sample experiment included in the E-Prime installation. This sample presents a choice reaction time experiment displaying a question with four response options. At designated times (i.e., delays), a Task Event calling the EliminateOption routine is triggered to disable the incorrect options, one at a time, until only the correct option remains.
The User Script in the ScriptTaskEvents sample experiment also includes the ClearAll routine for use in Task Events. The ClearAll routine resets the display options for the responses at the beginning of each trial. Note that the EliminateOption routine requires two parameters (i.e., c As Context, x As Integer), while the ClearAll routine requires only a single parameter (i.e., c As Context).
Add a Task Event
After the desired user-written script has been entered into the User Script window, it is available to be used within a Script Task Event. Next, add the desired Event that will be used to invoke the script via the Task Events tab on the appropriate object. Refer to E-STUDIO: Configuring Task Events  for detailed instructions concerning adding and configuring a Task Event.
Specify the Action
For a Script Task Event, the Action is selected from the script routines available in the experiment in User Script. In the Action field, use the dropdown menu to select from the available script routines. The image below illustrates the availability of the EliminateOption and ClearAll routines within the ScriptTaskEvents sample experiment.
If the routine requires a parameter other than varname As Context, the Parameter fields will be displayed, as shown in relation to selection of the EliminateOption routine in the image above. If the routine does not require a second parameter, the Parameter fields are not displayed. As shown below for selection of the ClearAll routine.
Define the Parameter
Refer to E-STUDIO: Configuring Task Events  for information pertaining to configuration of a parameter associated with a Script Task Event. When a script routine is selected as the Action for an event, and a parameter is required, the options for the fields available within the Parameter group will be determined by the definition of the routine within User Script.