If this template helps then use it. If not then just delete and start from scratch.
OS: macOS Catalina 10.15.4
PsychoPy version: 2020.1.2
Standard Standalone? (y/n) : y
So, I have this experiment that would run just fine in previous versions of PsychoPy. I updated the version of PsychoPy this morning and tried to run this experiment as usual, but it crashes every time.
There are some code components in a few routines (they are basically the same codes, just making reference to different text components), and I believe that’s where the problem is, since when I try to autogenerate the JS from Python so that I can upload it to Pavlovia, it says that there is a syntax error. What I don’t understand is why, since is was working just fine until yesterday/previous PsychoPy version I had in my computer.
I get the following message:
The codes I have are the following:
sentenceTREINOList = sentenceTREINO.split(’/’)
#this breaks your sentence’s single string of characters into a list of individual
#words, e.g. ‘The quick brown fox.’ becomes [‘The’, ‘quick’, ‘brown’, ‘fox.’]
#keep track of which word we are up to:
wordNumber = -1 # -1 as we haven’t started yet
#now define a function which we can use here and later on to replace letters with ‘x’:
def replaceWithX(textList, currentWordNumber):
xSentenceTREINO = '' for index, word in enumerate(textList): # cycle through the words and their index numbers if index != currentWordNumber: xSentenceTREINO = xSentenceTREINO + '_' * len(word) + ' ' # add a string of x characters else: xSentenceTREINO = xSentenceTREINO + word + ' ' # except for the current word return xSentenceTREINO # yields the manipulated sentence
now at the very beginning of the trial, we need to run this function for the
#first time. As the current word number is -1, it should make all words ‘x’.
#Use the actual name of your Builder text component here:
text_10.text = replaceWithX(sentenceTREINOList, wordNumber)
#In the Builder interface, specify a “constant” value for the text content, e.g.
#‘test’, so it doesn’t conflict with our code.
keypresses = event.getKeys() # returns a list of keypresses
if len(keypresses) > 0: # at least one key was pushed
if 'space' in keypresses: thisResponseTime = t # the current time in the trial wordNumber = wordNumber + 1 if wordNumber < len(sentenceTREINOList): if wordNumber == 0: # need to initialise a variable: timeOfLastResponse = 0 # save the inter response interval for this keypress, # in variables called IRI_0, IRI_1, etc: thisExp.addData('IRI_TREINO_' + str(wordNumber), thisResponseTime - timeOfLastResponse) timeOfLastResponse = thisResponseTime # update the text by masking all but the current word text_10.text = replaceWithX(sentenceTREINOList, wordNumber) else: continueRoutine = False # time to go on to the next trial elif 'escape' in keypresses: core.quit() # I think you'll need to handle quitting manually now.