Skip to content

Include Files

Include files (.rolinc) can be used to move a part of the code in the experiment file (.roleg) into a separate file. This code will still be interpreted if the separate include file is referenced from the original experiment file. ROLEG allows different include files to be used across participants, providing the opportunity to display different experiment parts to participant groups.

Important

If you make use of include files, be sure to test your experiment multiple times to try all the include files to ensure all run without problems. In the Live Editor you can use the Index of include file to use field, left of the Convert button, to cycle through your include files.

Restrictions

An include file is very similar to the main experiment file. However, instead of containing everything in an experiment block, everything should be contained within an include block. This block is functionally equivalent to an experiment block, but has the following restrictions.

  1. The available templates, font settings and errortexts are inherited from the point the include file is referenced in the main experiment file.
  2. No templates can be defined within an include file.
  3. Any font block or errortext block defined within the include file, will only be inherited by following trials within the include file and not extend to the main experiment.

Example usage

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 response lists.

forced_choice.roleg
experiment {
    include = ["choice1.rolinc", "choice2.rolinc"]
}

choice1.rolinc
include {
    trial {
        stimulus {
            text = "Make a choice"
        }
        response {
            choice {
                options = ["Dogs", "Cats", "Hamsters"]
            }
            button
        }
    }
}

choice2.rolinc
include {
    trial {
        stimulus {
            text = "Make a choice"
        }
        response {
            choice {
                options = ["Crocodiles", "Lizards", "Turtles"]
            }
            button
        }
    }
}

Because this example is spread across multiple files, you cannot open it in the Live Editor using the usual button. Instead, you can open the Live Editor manually, create the include files and copy-paste the code there.

In the experiment implemented in code above, the first participant will be presented with the options from choice1.rolinc. For the second participant, choice2.rolinc will be interpreted. Once the end of the list of include files has been reached, the process starts over. In other words, the third participant of this experiment will see the options indicated by choice1.rolinc again.

Combining with templates

The above example has include files that are identical on most lines. To avoid duplicating code, we can make use of a define_template block that is specified in the main experiment and used in the include files. The code below behaves identically to the example above. Especially when more trials are involved, this can help reduce the amount of script to write and help avoid mistakes.

forced_choice.roleg
experiment {
    // --- Template definition ---
    define_template {
        name = "forcedchoice"
        stimulus {
            text = "Make a choice"
        }
        response {
            choice {
                options = BOUND
            }
            button
        }
    }

    // --- Experiment trials ---
    include = ["choice1.rolinc", "choice2.rolinc"]
}

choice1.rolinc
include {
    forcedchoice_template {
        fill {
            options = ["Dogs", "Cats", "Hamsters"]
        }
    }
}

choice2.rolinc
include {
    forcedchoice_template {
        fill {
            options = ["Crocodiles", "Lizards", "Turtles"]
        }
    }
}

Back to top