| Reference | Downloads | Github

Reference Error: Words is not defined


I have a script that is working fine in PsychoPy. Now I am trying to put it online in Pavlovia to test it but I get some errors.
The experiment is only on Pilot now so I do not think I can share the link.

The error that I now get is “Reference Error: Words is not defined”
The auto generated code in my code component in end routine is:

var _pj;
function _pj_snippets(container) {
function in_es6(left, right) {
if (((right instanceof Array) || ((typeof right) === “string”))) {
return (right.indexOf(left) > (- 1));
} else {
if (((right instanceof Map) || (right instanceof Set) || (right instanceof WeakMap) || (right instanceof WeakSet))) {
return right.has(left);
} else {
return (left in right);
container[“in_es6”] = in_es6;
return container;
_pj = {};
if (_pj.in_es6(key_resp_oefen.keys, [“f”])) {
WordIteration.finished = true;
Counter = (Counter + 1);

However, I do not have Words in my code component for that part as you can see.
Anyone knows how to fix this error?

Thanks in advance!

Do you use Words as a variable anywhere?

Search the forum for a link to my crib sheet. X is not defined can usually be solved by defining it in a Begin Experiment code component tab

Best wishes


Words is only just as below (in the image).
I found your crib sheet, I only do not know how to define it in the Begin Experiment code component tab, I tried a few times but got the same error all the time.

I am sorry (I am really new in all of this), my script in Psychopy is also made with a lot of help because I didn’t use Python and/or Java before.

Thank you for your help!

I added now (" ") after split (what I saw in your chart and now the error is gone!!

Only now I get to see the text “Words[counter]” but that should refer and not be seen, the text should come out of an excel file… any idea what goes wrong now?

Ah. You are using a variable component. That’s a simplified form of code component, in your case Words = Sentences.split() which, according to my crib sheet, needs to be manually translated to Words=Sentences.split(’ ');

I think I will add “Don’t use variable components” to my crib sheet.

I think the reason why you can’t define it in a code component is because that’s conflicting with your variable component.

Yes adding the " " helped in getting the error out!! Thank you!!

Only now I get to see as what I showed above… the “Words[Counter]” instead of the words out of the excel file, do I need to refer it there differently?

In components you need to add a $, so $Words[Counter]