B.D.5
February 27, 2022, 5:30pm
1
Hello All,
I am constantly receiving the error below. I have a very similar another experiment but only one of them gives this error. I do not know why.
The error occurs when I try to define a correct answer in my code.
Here is a sample from my JS script in my code component. There are repetitions of this code for different conditions.
if ((wordChoice[0] === 6)) {
thisWord = word6;
thisWord_color = "Blue";
languageChoice.remove(6);
corr_AnsW = wmi_ret6W_2;
psychoJS.experiment.addData("corr_AnsW", "wmi_ret6W_2");
}
}
}
}
}
}
util.shuffle(languageChoice);
psychoJS.experiment.addData("languageN", languageChoice[0]);
if ((languageChoice[0] === 1)) {
thisLanguage = language1;
thisLanguage_color = "Red";
psychoJS.experiment.addData("Language", 1);
When I try to define correct answer for the language choice (as in the wordchoice), it gives the error.
util.shuffle(languageChoice);
psychoJS.experiment.addData("languageN", languageChoice[0]);
if ((languageChoice[0] === 1)) {
thisLanguage = language1;
thisLanguage_color = "Red";
psychoJS.experiment.addData("Language", 1);
corr_AnsLan = wmi_ret1W_2;
psychoJS.experiment.addData("corr_AnsLan", "wmi_ret1W_2");
P.S. I have no information about JS. I hope there is an easy-to-understand solution.
Bests
How many nested elif statements do you have?
Hello,
I’m getting below error message from my experiment when I try to update it. Before 2 weeks ago, I could update with no problem but now I get below error.
Could you please help me?
Traceback (most recent call last):
File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\app\builder\builder.py", line 1221, in onPavloviaSync
self.fileExport(htmlPath=htmlPath)
File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\app\builder\builder.py", line 719, in fileExport
targe…
B.D.5
February 27, 2022, 7:04pm
3
I have 5 conditions and within each condition i define 3 different variables to randomly select a number.
What I could not understand:
I am not adding an extra if statement
This does not create problem in other file even though everything is the same except the variable names (no “_2”s in the other)
Thank you
If you manually modified the JS code then I suspect that you have unbalanced brackets.
Copy and paste your JS code into Word and then search for { followed by } to compare the numbers of each.
B.D.5
February 27, 2022, 10:48pm
5
Yes, I am manually modifying only the code component.
No results found.
Since I can see instances in your post above, I can only assume that you copied and pasted the Python code rather than the JS.
B.D.5
February 27, 2022, 11:13pm
7
This was working in JS part
corr_AnsW = wmi_ret6W_2;
psychoJS.experiment.addData("corr_AnsW", "wmi_ret6W_2");
I just copied this and changed W to Lan.
Update: When I delete the line I indicated below, the error disappears.
util.shuffle(languageChoice);
psychoJS.experiment.addData("languageN", languageChoice[0]);
if ((languageChoice[0] === 1)) {
thisLanguage = language1;
thisLanguage_color = "Red";
#psychoJS.experiment.addData("Language", 1); # DELETED THIS IN ALL CONDS
corr_AnsLan = wmi_ret1W_2;
psychoJS.experiment.addData("corr_AnsLan", "wmi_ret1W_2");
Can this be only about exceeding max amount of Line in a code component?
if ((languageChoice[0] === 1)) {
thisLanguage = language1;
thisLanguage_color = "Red";
#psychoJS.experiment.addData("Language", 1); # DELETED THIS IN ALL CONDS
corr_AnsLan = wmi_ret1W_2;
psychoJS.experiment.addData("corr_AnsLan", "wmi_ret1W_2");
The above code has one { and zero }
B.D.5
February 28, 2022, 9:12am
9
I am sorry, not sure if understood it correctly
The { symbol is a bracket.
Every time you use it you are defining a section of code which starts at the { and ends at the next } symbol. If you don’t have a matching } symbol then the computer may assume that all of the rest of your code is part of that section.
In Python indents are used instead of { } brackets.
Try typing the following into an Auto translate code component.
if group == 1:
continueRoutine = False
The JS translation is:
if ((group === 1)) {
continueRoutine = false;
}
JavaScript has put ( ) brackets around the statement to be tested and { } brackets around the code to be executed if the statement is true.
1 Like