Hm, I think I really need that if-statement, otherwise the experiment crashes after each sentence (so indeed, when an IndexError occurs)… At least, that is what it does in Builder.
The catch statement alone should prevent it from crashing outright, but remember that running locally uses Python while running online uses JS, so the behavior you observe on your own computer may not be the same as what you see running in Pavlovia when you have complex code elements like this one.
Okay, so it should look like this?
if ((kb.length > 0)) {
if (_pj.in_es6("space", kb[0])) {
try {
nextWord = word_list.pop();
text.setText(nextWord);
} catch(e) {
throw e;
}
}
}
rtList.append(kb[0][1]);
}
Throw is the crash, effectively. It’s the behavior that causes the experiment to end and it to throw an error. What behavior are you looking for when it’s out of range?
By default this should be safe:
if ((kb.length > 0)) {
if (_pj.in_es6("space", kb[0])) {
try {
nextWord = word_list.pop();
text.setText(nextWord);
} catch(e) {
console.log('word_list depleted');
}
}
}
rtList.append(kb[0][1]);
}
but you could also stick in "continueRoutine = false; " if you want the trial to end at that point.
Hm, what happens now is that the sentences don’t show up at all, but immediately after the fixation cross, it moves on to the pause & question. This is the case for the practice trials, but then when I get to the real trials, I get the following error:
TypeError: trials.addData is not a function
It looks like you may have fixed this on your own, but for whatever reason I guess it didn’t populate the name of your trials loops correctly. Does it work now?
Yes it works now! There were two variables called “trials” which interfered with each other. I changed one of them to “study_trials” and that fixed the problem. I am now stuck with one last problem: the font size. It keeps appearing too big in the browser, even if I change the size/height in the code. Do you have any idea how I can fix this?
What units are you using? For whatever reason I have seen this happen with “height” units, and then changing to “norm” units (which are very similar) seems to fix it.
Oh I had it on “from exp settings”, changing it to “height” fixed the problem! 
I have one more question about the data. I have completed one pilot experiment, but the data does not show up here when I click “download results”. Do you know why that might be?
@jon, @dvbridges, or @apitiot might be better suited to answer this but my understanding is that when you pilot an experiment it downloads the results of the pilot run directly to your computer (the download prompt at the end) and does not save them to the server, but when you collect data with an actual run it is stored to the server and you will be able to download it.
Okay, the results of the pilot were indeed downloaded to my computer (but not stored to the server), so that might explain it!
Can I join into this conversation to ask a question: above where you state the issue about the clear Events error, I have the same and want to confirm in the two lines below that the place where it says clearEvents should be altered to the java version…
psychoJS.window.callOnFlip(function() { keyWelcomeScreen.**clearEvents**(); });
Is this where I should change to: “psychoJS.window.callOnFlip(function() {keyWelcomeScreen.PsychoJS.eventManager})”
keyWelcomeScreen is presumably a keyboard component, so it doesn’t have the function clearEvents to start with, because clearEvents is part of the PsychoPy “event” library (in Python). I think what you want is this:
psychoJS.window.callOnFlip(function() { PsychoJS.eventManager.clearEvents();});
Note that this clears out the entire event buffer on every frame, which may make it difficult to read off those events in the first place, but if that’s what you’re intending to do I think that should work.
Hi Jonathan, thanks for the suggestion, unfortunately it ended up causing the experiment to stop even earlier but maintained the same error. I’ve attached my experiment in case thats helpful, but the issue I’m having is still with the clear events which is occurring when usbjects are supposed to enter in letters they remember. Any other ideas? Trying to look through javascript but very new so unfamiliar with hte language.
Thanks,
KateOSPANrand.psyexp (62.5 KB)
I have two suggestions:
- In the code component, in “begin routine”, change the code type to “both” and on the JS side, change the code as follows:
modify = false;
text.text = "";
PsychoJS.eventManager.clearEvents();
- This is kind of in backwards order, but change the name of your text component from “text” to something unique. You might be getting some issues because “text” is both a property and the name of an object. You’ll need to change every mention of it in the code to the new name as well, of course.
Thank you! This was very helpful and worked!
I tried this and got the following error:
TypeError: psychoJS.eventManager is not a function
Hello @Emma_B,
To answer your question: results are not stored for piloting experiments, they are downloaded immediately at the end of the experiment session. You may remember witnessing your browser downloading a .csv file.
You can check the documentation page here: Pavlovia
Your results will be directly downloaded by your browser upon completion of the experiment, rather than being saved on the server (see the Download Results section below)
Alain
