User`s guide

E-Prime User’s Guide
Chapter 4: Using E-Basic
Page 151
Once declared in the User Script window, the variables are available globally, or for the scope of
the entire experiment. The variables must be initialized prior to the point in the experiment at
which they are referenced. This would be accomplished using an InLine object, inserted on the
Session Procedure timeline. The InLine may occur at any point prior to the referencing of the
variables; however, it is a good practice to insert the initialization InLine as the first event in the
Session Procedure. This InLine will serve to set up or initialize any variables that will be used.
In the example below, the Set command is used to initialize the PracticeProp summation variable.
This command defines the variable as a new instance of an existing object type. The TrialCount
variable is initialized to zero since no trials have yet been run.
'Initialize Summation Variable
Set PracticeProp = New Summation
'Initialize TrialCount Variable
TrialCount = 0
Once initialized, the variables may be assigned values and referenced within the context in which
they were defined. In this case, the defined context was the top-level context (i.e., User tab at the
experiment level). Thus, the variables are defined globally and may be referenced at any point in
the program.
The script below illustrates how the Summation and counter variables are assigned values on
each trial. The counter is manually incremented by one on each trial. The Summation variable
collects accuracy statistics across trials during the entire block. In the script below, the responses
are collected by the "Stimulus" object. Thus, the InLine that contains this script would follow the
Stimulus object on the trial Procedure.
'Increase counter by 1
TrialCount = TrialCount + 1
'Add accuracy stats to summation variable
PracticeProp.AddObservation CDbl (c.GetAttrib("Stimulus.ACC"))
'When trial count = 5, evaluate accuracy stats
If TrialCount >= 5 Then
'If accuracy is 80% or better exit block
If PracticeProp.Mean >= .80 Then
TrialList.Terminate
End If
End If
At five trials or more, the mean of the values collected by the Summation is evaluated. If mean
accuracy is greater than 80%, the currently running List (i.e., TrialList) is terminated. Thus, the
script examines the overall accuracy of the block and terminates the block when a minimum
accuracy of 80% is reached.
4.5.3.5 Example 5: Trial Level Variables
Declaring global variables permits the reference of these variables at any point in the experiment.
Variables to be used only within a specific context (e.g., block or trial Procedure) may be declared
using the Dim command in an InLine object in the appropriate Procedure. In the script below, the
Dim command is used to declare a variable to be used to collect a response on each trial. This
script is entered in an InLine object, which is called from the trial Procedure object.