Include files
Include files (.inc
) can be used to move a part of the code in the experiment file (.webexp
) into a separate file.
This code will still be interpreted if the separate include file is referenced from the original experiment file.
One motivation for using include files is similar to the motivation behind using procedures in more complex programming languages;
you want to avoid having to manually write the same code over and over again. This is done using the include
block,
which functions as a placeholder for code. The parameters of this block are summarized below.
Warning
If you make use of include files, be sure to test your experiment multiple times to try all the include files. Alternatively, edit your experiment to specify one include file at a time to test the included files selectively.
- files
- Required.
List of Strings that specify the file names of the include files (.inc) that should be executed at the point of reference. If multiple file names are specified, this block may achieve counterbalancing or randomization, see example experimental list.
Example usage
To show the use of an include
block, let us assume you want to show your participants multiple videos,
and you want to ask the same forced choice questions about each video. In this case, you can’t simply use a single choice block
in combination with a list of video names in the videofiles
element. After all, you want to ask more than one question.
Example without include
Without using include files, you would need to inefficiently script this experiment as described in the code snippet below.
experiment {
lexicaldecision {
priming {
video = "video1.mp4"
showtime = 10
}
decision {
display = "How does this video make you feel?"
advancekeys = "1234567"
response = ["Sad 1", "2", "3", "4", "5", "6", "7 Happy"]
}
decision {
display = "How does this video make you feel?"
advancekeys = "1234567"
response = ["Bored 1", "2", "3", "4", "5", "6", "7 Excited"]
}
priming {
video = "video2.mp4"
showtime = 10
}
decision {
display = "How does this video make you feel?"
advancekeys = "1234567"
response = ["Sad 1", "2", "3", "4", "5", "6", "7 Happy"]
}
decision {
display = "How does this video make you feel?"
advancekeys = "1234567"
response = ["Bored 1", "2", "3", "4", "5", "6", "7 Excited"]
}
}
}
As you will have noticed, this script is not very easy to read.
Example with include
By using include files, this can be made more clear and less redundant, see the code snippet below.
video_ratings.webexp
experiment {
lexicaldecision {
priming {
video = "video1.mp4"
showtime = 10
}
include {
files = ["questions.inc"]
}
priming {
video = "video2.mp4"
showtime = 5
}
include {
files = ["questions.inc"]
}
}
}
questions.inc
decision {
display = "How does this video make you feel?"
advancekeys = "1234567"
response = ["Sad 1", "2", "3", "4", "5", "6", "7 Happy"]
}
decision {
display = "How does this video make you feel?"
advancekeys = "1234567"
response = ["Bored 1", "2", "3", "4", "5", "6", "7 Excited"]
}
questions.inc
is referenced by inserting the special include
block
at the intended positions in the experiment file video_ratings.webexp
.
Example experimental list
In most experiments, you don’t want all participants to be presented with the stimuli in the same order. Instead, you should construct multiple lists using counterbalancing or randomization. Multiple lists can be implemented in ROLEG using include files. The code below illustrates how this works for a very simple forced choice experiment with two stimulus lists.
forced_choice.webexp
experiment {
info {
display = "You will take part in a self-paced reading experiment."
}
selfpacedreading {
include {
files = ["list1.inc","list2.inc"]
}
}
}
list1.inc
contentlist = [
["Once upon a time", "there was", "a noble prince"],
"He kissed a frog",
["The frog", "turned into", "a beautiful princess"]
]
list2.inc
contentlist = [
["What would you", "do if you had", "a million dollars?"],
["Try not to spend it all at once", "my mother would say"],
"Worries for later"
]
In the experiment implemented in code above, the first participant will be presented with the order of stimuli in list1.inc
.
For the second participant, list2.inc
will be interpreted. Once the end of the list of include files in files has been reached,
the process starts over. In other words, the third participant of this experiment will see the stimuli in the order indicated by list1.inc
.