Use a variable for the conditions file path on pavlovia

Hi there,
is it possible to use a variable file path for condition files on pavlovia?
The following works just fine locally (Builder with a code component):

I have two routines: start and trial. There is a loop trials around trial.

For the loop I set the file path for the conditions file to
In a code component (located in start and under “Begin Experiment”) I initialise the variable filepath_conditions based on input from expInfo['treatment] (user input from the form before starting the experiment):

filepath_conditions = 'cond_control.xlsx'

if expInfo['treatment'] == '1':
    filepath_conditions = 'cond_treatment.xlsx'

Both files are in the same directoy as the experiment itself.

This does pretty much what I want: When the user input for treatment is 0, then the conditions file for the control group is used. And when it’s 1, the the conditions file for the treatment group is used.

This does not work on pavlovia, though. It always gives me an error

Unfortunately we encountered the following error:

  • when importing condition: cond_control.xlsx
  • when getting the value of resource: cond_control.xlsx
  • unknown resource

Is it just no possible at all or am I missing something?
If its not possible I can just use different routines - but I thought that it was a much more elegant way to do it this way.

You either need to attach all possible filepath_conditions files in Experiment Settings / Online

Alternatively you can use prepareResources to attach the required file on the fly.

1 Like