Setting Text Duration to Variable Within a Loop

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): Win 10
PsychoPy version (e.g. 1.84.x): PsychoPy 2021.1.2
Standard Standalone? (y/n) If not then what?: Yes
What are you trying to achieve?: I have a set of six instructions contained in a .csv file under the variable InstrText and the desired duration that the text should appear on the screen in a separate column titled TextDuration. A loop iterates through these instructions sequentially and the text variable works fine. The amount of text on the screen is variable, so I’d like to vary the time that it appears as well. When I set Stop: Duration (s) to $TextDuration, the error at the bottom appeared. I’m new to the builder, so I don’t understand why this syntax is invalid. I have noticed that I cannot set duration to Set Every Repeat like I can with the text. Wondering then if it’s only possible in the coder.

What did you try to make it work?: I’ve looked around on this forum and found plenty of folks reporting they’ve been able to set duration as a variable, but, again, wondering if I need to switch to the coder for that.

What specifically went wrong when you tried that?:

 File "C:\Users\Administrator\...\Experiment_lastrun.py", line 154
    if tThisFlipGlobal > IntroInstr_Text.tStartRefresh + asarray($TextDuration)-frameTolerance:
                                                                 ^
SyntaxError: invalid syntax

Thanks for your time!

It should work

However, it could be a bug in your version. I avoided 2021.1.0 to 2021.1.2.

1 Like

Okay, just knowing it should work is good to know. I’m updating my version, so hopefully that’ll fix it. Thanks!

It was not a version issue. For some reason, we do not need to specify the $ for the duration (even though one does not appear to the left of the text entry box). Once I removed that, it worked fine.

2 Likes