macOS Sequoia 15.3.2, macBook Air M1
PsychoPy v2024.2.4, python 3.12.1 (macOS terminal: python3 --version) Standard Standalone Installation? yes Do you want it to also run online? yes
Hi there,
i have created an experiment for a project at my university. It runs fine locally but won’t run on pavlovia. In the browser Debugger it says Uncaught ReferenceError: assignment to undeclared variable partid. In the first routine i have custom code (Auto->JS): partid = randint(1,999999) which gets translated to partid = util.randint(1, 999999);. ChatGPT says that it should be var partid = util.randint(1, 999999);. I searched here for compilation error and found nothing fitting for my case, mostly things about other parts of other routines having faulty code. While that may be the case also, i created a new empty experiment, added the custom code ARandomVar = "Hi There" and it still compiles without the var statement, so compiling seems somewhat broken on my machine.
I also looked for requirememts to run/compile code, but couldn’t find any on the installation page.
wkr
// Edit: The Code is in the “Before Experiment” Tab of the custom code.
// Edit: As is understand from Issues With Debugging PsychoJS files - #6 by dvbridges, by not compiling with a var statement, psychopy tries to declare the variables globally. I tried with newest Firefox and Edge versions now locally and with pavlovia, they both are upset with the missing var.
As i said, i wrote it in regular python and the code component is set to “Auto->JS” which should translate the code to JS fine, as per the documentation.
Thanks wakecarter, i think this cleared up my understanding of the tabs in the code component. I moved most variables to “Begin experiment”.
I need partid for the name of the data file, so i switched the code component to “Both” and declared it “Before Experiment” with var. This seems to work fine, partid is available throughout the experiment.