Uncaught syntax error

URL of experiment: https://run.pavlovia.org/MJB/fapesp-time_estimation/html/

Description of the problem: uncaught syntax error

The line the error points at reads:

 if (FP_2.status === PsychoJS.Status.STARTED && Boolean(((Causal_S2.status == (- 1)) and (t > ((Interval + 1) + (0.5 * np.random.random())))))) {

This is not something I wrote, so must have been created by PsychJS.
Any pointers what is going on here?



@Marc_Buehner, the ‘and’ logical operator is different in JS. try:

Causal_S2.status == (- 1)) && (t > ((Interval + 1)

@dvbridges that’s really strange because I did not write that – that is PsychoJS compilation.

I’ve changed it, but for some reason when I run the experiment, it still throws the same error, and it looks as if the code has not changed. Perhaps this is me not understanding how to work gitHub?
Where can I get a dummy’s guide on how to make small edits for gotchas like this?

THanks, as always!

This is an unintuitive thing I’ve just discovered about Pavlovia. If you set your experiment to “inactive” and then back to “piloting”, it should reload the code from the repository. If you didn’t do that, I think it’s just using whatever code it had lasts time you set it to piloting.

This is your conditional duration of your FP_2 text component, so you will need to change the component in Builder, rather than making the change on GitHub. After this, resync with Pavlovia. Actually, it is recommend that all changes are made via Builder, otherwise you may end up with merge conflicts if you make changes online, and then switch to Builder and make similar changes there.

If you have made your changes online already, I recommend that you do the following:

  1. Go to experiment settings > online
  2. Set Export HTML to “manually”
  3. Sync experiment, to get online changes on your local computer
  4. Go to experiment settings > online
  5. Set Export HTML to “on sync”

This should hopefully stop any merge conflicts.

HI @dvbridges – thanks for this. I can see where it happened.
However, I cannot actually make the change in builder:
It then complains of a syntax error and won’t let me click the OK button (if I replace the ‘and’ with && in the condition box)

I see, then in that case, you might want to try adding a code component above that text component in the routine. In this code component, create a new variable in the Begin Experiment tab, e.g., FP_2_duration = false;, or use another name to represent the duration of that component. Then, in the Each Frame tab, add

FP_2_duration = (Causal_S2.status == (- 1) && t > (Interval + 1))

Now you have the boolean value from this expression in a variable, you can pass it to the text component duration field. This should remove the syntax error. Note, you will have to do this for both Python and JS code, but for the Python version, use:

# Begin Experiment
FP_2_duration = False

# Each Frame
FP_2_duration = (Causal_S2.status == (- 1) and t > (Interval + 1))

Thanks @dvbridges. I have done this and replaced various bits of code that used numpy with Math().
But I still get get the nasty frameDur not specified error that others have been documenting.
@jon suggests that other bits of code are not correct. Do I need to worry about declaring FP_2_duration as a variable at the start in some piece of code (and the other variables that now use Math()? Or does the translator do that for me?
I am really finding this exceedingly difficult to get to work :frowning:
Thanks, as always!

@Marc_Buehner, the frameDur error means that there has been an error compiling your code. If you are using an up to date version of PsychoPy, there should be an error output that tells you the line that the compiler has failed on.

@dvbridges – thanks for this. I just downloaded the latest standalone. Where would I need to look for an error when compiling code? Is that when I sync w Pavlovia? I don’t get anything there.

Some logging shows up in the “Run” window when you sync an experiment, check there.