URL of experiment: https://run.pavlovia.org/holmit/computerstimmen1
Description of the problem: Using Builder with extensive use of code snippets, I am trying to read in files during the experiment for sound files and also the loop conditions file. I generate the order to be read in at the start of the experiment (begin routine tab, first trial)
myChoice = Math.floor(Math.random() * 64) + 1;
if (myChoice < 10) {
myOrderString = "0".concat(myChoice.toString())
}else{
myOrderString = myChoice.toString() }
block1Order = ("order_bl1_" + myOrderString + ".csv")
block2Order = ("order_bl2_" + myOrderString +".csv")
console.log(block1Order)
Even though this looked fine in the console (the resulting string looked as planned),
this gave rise to “unknown reference errors”, like the following:
###############
Unfortunately we encountered the following error:
when importing condition: orders/order_bl1_14.csv
when getting the value of resource: orders/order_bl1_14.csv
unknown resource
Try to run the experiment again. If the error persists, contact the experiment designer.
#############
I checked on github that the file is there in the subfolder “orders”.
Strangely enough, if I copy the “orders/order_bl1_14.csv” from the error message,
put that into the conditions tab for the loop everything works.
( I also tried losing the subfolder, by putting all my csv files (many…) in the same folder as the index.html, with no success.)
I had the same problem with reading in sound files, which were given as somthing.mp3 in the csv input,
and then supplied with the path in a code snippet:
soundFileL = "sounds/".concat(soundFile);
This again give rise to an “unknown resource error”. I could solve that problem by adding the “sounds/” part to the soundfile specification in the csv file, but I really would like to understand why the file is found when specified as “sounds/something.mp3” in the conditions csv file, but not found if specificed as “something.mp3” in the conditions file, with the path added during execution (and yes, I did change the variable in the sound itself to soundFileL).
Can anybody explain what’s going on? Is there some string interpretation going on when putting these variables into the tabs of the experiment objects?
Kind regards,
Holger