Using dashes (self-paced reading)

You need to remove the additional tabs in your reading_code component which are causing the syntax error.

(code_clock will currently fail online but should be final locally)

Thank you for your response.

Would you please elaborate more on this?

I have 2 tabs in my reading_code.

This is what I have in the Begin Routine:

for Idx in range(lines):

    mask[Idx].vertices=[[0,-fontSize/10],[lineLength[Idx]*fontSize*.33,-fontSize/10]]
    mask[Idx].pos=[-.5,lineSpacing*(fontSize*Math.floor(lines/2)-fontSize*Idx)]
    mask[Idx].setAutoDraw(True)

And this is what I have in Each Frame:

Thanks

I think I may be confusing you with the word tab. Your indents are causing a Syntax error.

Aha!
Ok. This is the code that you wrote for me. Sorry, I am not familiar with coding at all. Would you please remove the additional indentations? The code is as follows.

wordLength=(len(words[wordNum])+2)
reading_bg.size=[wordLengthfontSize5,fontSize8]
reading_bg.pos=[-.5+(len(phrase)+wordLength/2)fontSize.33,lineSpacing
(fontSizeMath.floor(lines/2)-fontSizethisLine)]
reading_text.text=words[wordNum]
reading_text.pos=[-.5+len(phrase)fontSize.33,lineSpacing*(fontSizeMath.floor(lines/2)-fontSizethisLine)]
phrase+=words[wordNum]+’ ’
if wordNum > nWords-2:
pass
elif len(phrase) + len(words[wordNum+1]) > lineLength[thisLine]:
phrase = ‘’
thisLine += 1

Thank you

wordLength=(len(words[wordNum])+2)
reading_bg.size=[wordLengthfontSize5,fontSize8]
reading_bg.pos=[-.5+(len(phrase)+wordLength/2)fontSize.33,lineSpacing(fontSizeMath.floor(lines/2)-fontSizethisLine)]
reading_text.text=words[wordNum]
reading_text.pos=[-.5+len(phrase)fontSize.33,lineSpacing*(fontSizeMath.floor(lines/2)-fontSizethisLine)]
phrase+=words[wordNum]+' '
if wordNum > nWords-2:
     pass
elif len(phrase) + len(words[wordNum+1]) > lineLength[thisLine]:
     phrase = ''
     thisLine += 1
1 Like

unfortunately, this error again appeared. I think I’ve done sth wrong.

Experiment.psyexp (64.5 KB)

Hi
I hope you are fine

sorry, would you please look at the above screenshot?

I have copied and pasted the new code that you gave me.
The error again popped up (/* Syntax Error: Fix Python code */).
Where do you think the problem lies?

There are issues with the maths. For example, should len(phrase)fontSize.33 be len(phrase) * fontSize * .33 ?

There’s at least a couple of errors like that

Aha
Thank you

Unfortunately, I am not familiar with coding at all.
IDK what to say.
would you please tell me how I can solve the coding problem? I just want to mask words and phrases with dashes…

If there is no way to solve the coding problem, please help me with the second solution.

I myself prefer the the first solution.

the second solution: I think it is possible to mask sentences in Excel. I mean, instead of having a code component, I can mask sentences in Excel. Please look at the following screenshot:

Instead of *s, can I have dashes or minus sign??

unfortunately, when I use minus sign (-) for example, Psychopy shows this error once the sentence is read:

Also, there is a lack of correspondence between letters and minus signs…

if possible, would you please help me with coding?
please help me whenever you have time

Thank you very much