How to get a response from a textbox in one routine to appear in a different routine?

OS Win10
PsychoPy version v2023.2.2

What are you trying to achieve?:
Hi everyone, we are creating a reaction time study in which participants need to input the name of two different friends. They will then be shown the name of one of the two friends along with an emotion word and asked to rate how strongly they feel/ connect that emotion to that friend on a 1 to 5 scale. This will be repeated for 120 random trials, with sixty emotion words being asked about friend 1 and the other 60 being asked about friend 2. We are very new to Python and Psychopy and wanted to know if this is possible.

What did you try to make it work?:

Participants will be inputting their friend names into two different text boxes (friend 1 will be typed in textbox 1). In a later routine, we want to refer back to these names that have been typed in the textboxes, but we are unsure how to do this. We have tried putting in $Friend1Resp and $Friend2Resp (the name of the textbox responses) in the text component of our stimulus routine, but this just showed up as $Friend1Resp when we ran it.

We also tried to define the variable in a custom code component using “Friend1 = Friend1Resp.text” in the EndRoutine tab. Our thought process was to take the “Friend1Resp.text” and define it as “Friend1”. We then put $Friend1 into our stimulus routine in the text component, but when we ran it showed up as “$Friend1” and not the participant response.

Thanks for your time!

Hi @Zulma_Guasch , to use the response from a textbox in a text component, you need to refer to the textbox text in the textbox component using $textbox-name.text, and set the text component to update “on every repeat”.

Attached is a very simple example. Click the textbox to start typing, and click the button to end the trial and see the textbox text displayed in the text component.

text.psyexp (15.2 KB)

1 Like

Thanks so much! It worked!

We were able to figure out how to refer back to a textbox text from a previous routine! However, we have another problem we’re trying to solve.

For our experiment, we will be presenting 60 emotion words paired to one friend name, and do the same with the second friend name. Together there will be 120 trials. The issue we are having is that we do not know how to randomize the order of the two names popping up over the course of the 120 trials. The emotion words are already randomized as we wanted, but the friend names are not yet. How would we do this?

We first tried to create two stimuli routines, one for each friend name, and we put those in one loop. This resulted in the friend names alternating every trial, which is not what we want. We then tried to create two different loops, one for each friend, for 60 trials each. We then looped the two loops together to see if it would randomize the two loops. This resulted in displaying all 60 trials for friend1 first and then all 60 trials for friend2 second. How would we go about randomizing the order of the two names displayed?

Thank you for your time in helping us!