Like many others on this forum, my experiment runs in PsychoPy, but not in Pavlovia. The error I get is the one above, although the number changes per run. I have read the other threads with this topic but it seems to be something different every time. I have translated all the code to JS (with a lot of help from an awesome user on this forum) but to no avail.
The full error in Javascript is this (this time number 9):
core-2020.1.js:1437 TypeError: Cannot read property '9' of undefined
at Scheduler._currentTask (Experiment_EliseAlberts.js:2002)
at Scheduler._runNextTasks (util-2020.1.js:1091)
at Scheduler._runNextTasks (util-2020.1.js:1094)
at Scheduler._runNextTasks (util-2020.1.js:1094)
at Scheduler._runNextTasks (util-2020.1.js:1094)
at update (util-2020.1.js:1058)
Does anyone have any suggestions on how to solve this? Thank you!
Is there a way to circumvent putting this code directly in the text component but instead using a custom code? That way Psychopy should automatically translate it to JSā¦
You call the loops different things in PsychoPy but then refer to them all as trials in PsychoJS.
Did you get len is not defined as an online error? It looks like len in Python is getting translated to .length in Javascript so Iām wondering whether thereās another reference to len somewhere in your code. Iāve been loading up the Javascript code from the git repository and then searching for the offending term.
I was beginning to lose hope with Ebbinghaus Darts but I think Iām now there and have learned a lot in the process. Some things wonāt work but most of it seems to be fine once you get your head around it.
Yes I got it as an online error, and youāre right: I had one loop with still the len function. I implemented it everywhere and Iām getting closer! I am only getting this error again:
core-2020.1.js:1437 TypeError: SentAfterPrac.split is not a function
So it doesnāt recognise it as a JS function I guess. Which is strange because from what I can see online, this seems the way to do it. My experiment runs, but doesnāt split up the sentences into words like I wanted it to do - instead, it displays the full sentence (which is in the excel file). But still. Iām one step further!
Good to hear you got yours to work. Do you have any more suggestions for this problem?
It looks there is at least one place in your code where you have SentAfterPrac.split() rather than SentAfterPrac.split(" "). This is probably why you get the whole sentence displayed rather than individual words in succession.
The TypeError .split is not a function that you are getting typically means that SentAfterPrac is not a string. So I would check the file that loads this variable and see how the trial that elicits this error might be different from the others.
KEITH you are an absolute angel of a human being. IT WORKS.
Okay so Iāll summarise the issues I had to fix before it finally worked for others if they need a similar fix. Also hereās a quick summary of what the experiment is actually doing for those who are interested, and if anyone needs to create a similar one:
During the experiment, participants see words appearing one by one on the screen. Together, these words form a sentence. One word in the sentence is substituted by a picture. Next, a letter will appear in the middle of the screen. Their task is to indicate whether the sound of this letter is present in the picture name and they will be given feedback to this.
The excel list, thus, consists of a āsentencebeforeā list and a āsentenceafterā list with what needs to appear before and after the picture and the letter. However, one problem that I JUST realised because of your comment, Keith, is that this means there are sometimes cells containing only ātheā or cells containing only an enter (because the sentence ends with the picture). This did work in Psychopy, which is why I was so confused when I got the error. What I did now, is I put words in every cell (right now it says āboo booā because thatās my mood) and now it does recognise it as a string. I do need to still find a solution how to create a āfakeā string of words that will not be seen by the participant but I think Iāll be able to find something.
Some things I did (with a lot of help from your replies) before it worked in Pavlovia:
Replace all the custom names for loops to ātrialsā in the Javascript code (code > both > edit the JS translation)
Define the len(SentAfterPrac.split()) in one of the custom codes boxes first, so that the code included the JS translation (instead of putting it in the $rep in the loop options box) - and this is important for any code that you put directly in the variable box.
The JS code for len(SentAfterPrac.split()) is indeed SentAfterPrac.split(" ").length; and crucially NOT SentAfterPrac.split().length; which is what PsychoPy automatically translates it to.
Thanks again Keith and Wakecarter! Youāve been a big help!
Hi Elise,
can I ask you some questions on the three points how you fixed the problem.
So the first thing to to is to add a loop to my routine which only consists of the image, the rating scale and a keyresponse to end the routine, right? The loop is only called trials and what should be clicked/inserted there. No condition file and for nreps? 1?
Then I add a code component to my routine. Selected both and then? What is the code?
Iām so sorry Iām a absolute newbie here