ReferenceError: screen_text is not defined

Go through your Builder file.

Set all components to Auto except:

  1. One code component in your first routine should be set to JS (for code_JS as per my crib sheet)

  2. If you have components that need manual translations, switch them from Auto to Both and then edit the JS side.

Thank you, but this is what i had done originally, where i had the code components said to auto and then changed to both for the ones i had to edit on the JS side.
in regards to point 1 - to clarify, i should make another code component in my first routine (so this would be ‘instr’ for me), and then set this to JS, such as this:


and then copy this into the begin experiment tab: PsychoPolyFill(expInfo.psychopyVersion, psychoJS, util); ?
i dont quite understand what to write in the before experiment tab however

Correct – I’d recommend that you try the given suggestion in Before Experiment

import PsychoPolyFill from 'https://run.pavlovia.org/tpronk/demo_polyfill/PsychoPolyfill.js';

What does it mean by import psychofill? So do I click on the link and copy all of the text? Or copy as what you have sent?

This

hi i have done that but i am getting this error when trying to run the task and i am unable to get it to the runner:

to double check i havent done something incorrect, this is what i did:

  1. Made a new component in the ‘instr’ routine (which is my first routine) called code_JS.
  2. Added this in the before experiment tab:
  3. And this in the begin experiment tab:

Are you trying to do local online testing? I get that error message but it doesn’t stop me syncing and testing online.

Yes that works! I was unable to sync it onto the previous one for some reason, so i uploaded it as a new task on psychopy called ‘Digit Span’. i have added you as developer on this one as the last one isnt sync’d.

It is working now, however, the last digit from each trial shows the answers from the previous trials if that makes sense?
EG/ if you typed in the answer of one of the trials as 239, then on the next when the digits are presented it would show for example ‘4, 7, 8, 239’. And then you are prompted to write the answer. I am unsure if that is a clear explanation but do you know why this may be the case? I have never had this issue before within psychopy itself

Try moving your code block to the top of the routine and / or setting screen_text = ’ ’ in End Routine so it’s definitely clear before the next routine starts.

do you think it would be a good idea to move the code blocks of every routine to the top?
and for the second suggestion, which routine would i do this for, all the presentation routines? or also for the response routines?

It’s good policy to have code blocks at the top (except when you know why they can’t be).

For the second suggestion, this is for routines where screen_text gets edited.

i have moved my codes to the top, thanks for the suggestion.
in regards to the screen_text line in end routine, this is what i have for one of the routines:


would i delete both lines and then add screen_text = ’ ’ in the py side? (and then find the relevant corresponding code for js of course)

Yes if you don’t know what that code is for.

i am getting a syntax error:


maybe i am typing it wrong into the builder?

Retype the quotes to make them 'dumb' not ‘.smart’

thanks! i retyped it and it allowed me to retrieve the js code too.
however, i have implemented both the suggestions but i am still getting the same error for some reason…
im also not able to sync it onto the same task once again (im not sure why this has been happening) so ive had to add a new task called ‘ds’ on pavlovia. i have added you as a developer also.

Are you saving to a cloud storage folder like OneDrive?

I have saved it onto my MacBook desktop, not on anything else. I usually can sync easily but the past couple days it isn’t allowing me to. But it says sync successful when I try to do it via ‘search’

Also, do you have any suggestions as to why I am still getting the error where the previous answers are showing? I tried both the screen_text code change and moved all the codes to the top but with no luck. I can’t seem to find anything on any other forums either about this

Here’s my theory.

When something is set every frame then it appears with it’s previous value and then gets set, so there is a one frame hangover from the previous trial.

Clearing screen_text doesn’t help this because it gets cleared after the last frame of the previous routine.

I think that if you explicitly clear the contents using textFeedback.text = ' ' as well as screen_text = ' ' in Begin Routine then it should work. However, I’m going to leave you to test this instead of syncing to your new experiment repository.

i added both lines onto the code for begin routine in all 3 response routines (trial, forwards, and backwards routines).
just wanted to double check, did you mean something like this:

i was also wondering, as the issue is arising in the actual presentation of the numbers, i was thinking i should add the code to begin routine for the presentation routines also? but i am unsure so wanted your advice on that