URL of experiment: https://run.pavlovia.org/MarkovYA/animalsearch3/html/
Description of the problem: I tried for several times to create new project, but I still stuck on the initializing experiment screen. I am using v2020.1.3. Thanks!
URL of experiment: https://run.pavlovia.org/MarkovYA/animalsearch3/html/
Description of the problem: I tried for several times to create new project, but I still stuck on the initializing experiment screen. I am using v2020.1.3. Thanks!
When I open the web debugging console in chrome it says thereās a syntax error in your code because of the line
import * as random from 'random';
apparently that needs to be at the top of the file in JS. I guess we need to find a way that additional JS modules can be imported without breaking studies! :-/
Thank you! I fixed this by deleting all auto translated code and replacing it by my JS script. I have random module in Py code and it is translated into this in JS as import * as random from ārandomā;.
OK. thanks for letting me know. Out of interest, did you then move the code to another spot, or did you not need the import statement at all in your final version?
I had this in Python in code block
import random z=randint(1,32)
And instead of this I just wrote this in JS:
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
z=getRandomInt(1,32)
Actually when I start PsychoPy it is sometime ruins my JS code in code block and put autotranslated code instead.
Hi both @Yura_Markov @jon , I think have the same problem. This is what I got in Stdout:
Alert 4210:JavaScript Syntax Error in āBegin JS Experimentā tab. See āLine 1: Unexpected tokenā in the āBegin JS Experimentā tab.
8415.2480 ERROR Line 111: Unexpected token in Pri_word.js
8416.0981 ERROR Line 103: Unexpected token in Pri_word-legacy-browsers.js
This is the error line
inicodeClock = new util.Clock();
Below this line are these two lines
import * as random from 'random';
import * as xlrd from 'xlrd';
Do you know how to fix this? thanks a lot!
URL of experiment: https://run.pavlovia.org/xiaotong/concurrent-task/html
I have same problem here and get stuck here for several days. so frustratingā¦
I am wondering whether we can use āimportā in JS.
@Ethan @Xiaotong I think that you canāt use import random in JS. So, it is better to use functions that I described higher. You just need to change auto PY->JS to both and manually write correct code
Yes, although importing libs is possible in JS we havenāt yet exposed an entry point high enough in the script to allow you to do it. Weāā work on that for a future version but in the meantime @Yura_Markov solution is the one
Is this the only solution? Iāve tried this solution and still receive the same error.
Is this the only solution? Iāve done this but still receive an error following a read of a wordlist csv in a loop.
Iām having the same issue as above, details in post here: Error syncing from builder
My confusion is that I have not written any code manually as the above posts seem to indicate had caused this issue. I just used point and click in builder.
Like @memlab my issue seems related to a csv list of files used as the condition in a loop.
Sorry, Iām not quite understanding the solution.
Here is the link to the my experiment: Zared / Diss - Pilot Sentence Norming Ā· GitLab (pavlovia.org)
Iām having this same problem for seemingly the same reason. I had a code component to create and randomly shuffle some lists as part of my complex stimulus randomization scheme.
I also used autotranslate Py-JS. Iām quite proficient with Python, know 0 with JS and this is my first rodeo uploading to Pavlovia.
I put the following in Begin Experiment:
fillArr = np.random.choice(range(5,62), size = 21,replace = False)
firFiveFill = [i for i in range(5)]
fill = fillArr.tolist()
mystArr = np.random.choice(range(62,157), size = 32,replace = False)
myst = mystArr.tolist()
order = fill+myst
random.shuffle(order)
stories = firFiveFill + order
I put in import random
Before Experiment.
Is the error with the random choice function or with the import random?
I am experiencing the same problem, when I look at the line of code the error message mentions I see import statements but none of it is code I wrote, itās like:
āimport { PsychoJS } from ā./lib/core-2020.2.jsā;
import * as core from ā./lib/core-2020.2.jsā;
import { TrialHandler } from ā./lib/data-2020.2.jsā;
import { Scheduler } from ā./lib/util-2020.2.jsā;
import * as visual from ā./lib/visual-2020.2.jsā;
import * as sound from ā./lib/sound-2020.2.jsā;
import * as util from ā./lib/util-2020.2.jsā;ā
Do you think that these are also causing problems?