PeKos
November 13, 2023, 11:05am
1
URL of experiment:
Description of the problem:
Hello everybody!
Asking for help - how to define a simple list of txt strings in JS, to work in Pavlovia online.
“Manually” (because it was not translated from the Python code) in Java script I entered Java declaration:
String[] strAr1=new String[] {“aa”, “bb”, “cc”}; //or:
String[] strAr2 = {“aa”, “bb”, “cc”};
but still, despite many attempts errors appears. In the HTML source I can watch the error message, that the list is not declared.
Thank you in advance.
The Auto translate works fine for lists. What error are you getting?
PeKos
November 13, 2023, 1:41pm
3
Thank you very much for your quick response.
I was also surprised, that auto-translation has problem with simply lists.
From Psychopy Coder in python script I have definitions of my variables:
Run ‘Before Experiment’ code from code1
Definition of my variables:
machine1_list = [“LOOSE”, “WIN”, “WIN”, “LOOSE”]
machine2_list = [“WIN”, “WIN”, “LOOSE”, “WIN”]
N1 = 0
N2 = 0
and in JS no translation just:
// Start code blocks for ‘Before Experiment’
// Run ‘Before Experiment’ code from code1
machine1_list = [“LOOSE”, “WIN”, “WIN”, “LOOSE”];
machine2_list = [“WIN”, “WIN”, “LOOSE”, “WIN”];
N1 = 0;
N2 = 0;
then when trying to run in Pavlovia online I get “machine1_list not defined” error (HTML source preview in DevTools):
Kind Regards.
Define your variables in Begin Experiment, not Before Experiment
PeKos
November 13, 2023, 2:21pm
5
Thx very much. I will check it today.
Have a good day!
PeKos
November 13, 2023, 7:18pm
6
Done. Thank You once again.