Experiment
Init
Initialize necessary global variables you have declared in the User scriptMainly for setting up variables or doing logic that remains the same for the rest of the program (e.g. search element positions)Set canvasses that are dim-med in User Script
Logic that remains the same for the rest of the program
Set up variables
Initialize global variables
User Script
Eprime allows you to declare, but not initialize (assign values to) variables in the User script. This has to be done in the Init script. Constants however have to be initialized immediately.
Subroutines
Some segments of code might need to be executed at various locations in the program --> make a subroutineA subroutine is a collection of code which can be called at any location in the program.Subroutines should be defined in the beginning of the program (after constants and global variables)Functions
A function is like a subroutine, but returns a single value of a type you specify
Global Variables (incl. arrays etc.)
Variables in E-basic:
Declared with the keyword Dim (dimension)Variable name must start with a letter but may contain other alphanumeric characters. If it consists of more words Use CamelCase: thisIsAVeryLongNamedVariable Use underscores: this_is_another_long_named_variableHave to be assigned a datatypeExample:
Dim age as integer
age can now be referred to and integer values can be assigned to it:age = 28 (age + age will return 56)
Other datatypes:
Integer Any number between –32,768 and 32,767Long Any number between –2,147,483,648 and 2,147,483,647Double Any real number between: Negative –1.797693134862315E308 <= double <= –4.94066E-324 Positive 4.94066E-324 <= double <= 1.797693134862315E308String a string of characters contained within “”For example: “boat” or “experiment”Boolean True or false (e.g. isRaining = true)Currency, Date, Variant, etc.Type declarations
Type declaration:
Type Person
name as String
age as integer
gender as String
End Type
Now you can declare this type like any other variable and access its contents through the “dot notation”
Dim member as Person member.name = “John” member.age = 25 member.gender = “male”Constants
Constants can only be assigned a value once, which cannot be changed afterwardsConstants are always defined at the beginning of the programConvention: constant names are specified in uppercase
const NO_OF_PERSONS as integer = 5Note: value is assigned directly at declaration, not afterwards as is the case with variables.
Script in Procedures
Do logic specific to blocks and trials
Get values of list attributesSet up canvasesDraw canvasesDo stuff with participant’s responses (play correct/incorrect sound, change color of fixation cross depending on correctness)Keep track of participant scoresTrial specific
randomize
you can randomize things by dirctly putting it into the code variable = random (min rand no, max rand no) or you can put it in a list and work with c.getAttrib, the plus side when doing this is that it is recorded and you know when what is presented in which trial. Randomisation can be done by putting the list in the ramdom mode. Downside is that it may create a lot of extra trials because every position has to be presented before end of the trial.
Block specific
Give feedback to respnses (visual/auditory)
Keep track of participant scores
Draw Canvasses
Set up Canvasses
Get values of list attributes