Loop & text componet

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

OS (e.g. Win10): Win11
PsychoPy version (e.g. 1.84.x): 2023.1.3

I’m going to use Loop. First of all, the excel file I have is like this, ‘sentence’ is the variable name, and the unfinished sentences below are the stimuli.(figure 1)

1
](https://)

And in the previous trial of loop, I set the code for participants to enter names in the variable ‘name’. (figure 1-1)

So I wanted the name + sentence to come out when the loop was implemented. For example, if the name you entered is John, then John is happy. So I tried a total of three things.

  1. Enter $name + $sentence directly into text component
    → Just ‘name+$sentence’ comes out in screen

  2. Add code component, add code to Begin Routine. And enter $text2 in text component. I’ve done both, but neither of them works(of course, I text $text2 in text component)
    → It said ‘text2 is undefined’

text2 = "{} {}".format(name, sentence)

or

sentence=trials['sentence']
text2 = "{} {}".format(name, sentence)
  1. When I modified the code in coder, it executed well. However, the modification was not reflected in the builder. I want to know the solution.
if thisTrial != None:
    for paramName in thisTrial:
        exec('{} = thisTrial[paramName]'.format(paramName))

for thisTrial in trials:
    currentLoop = trials
    # abbreviate parameter names if possible (e.g. rgb = thisTrial.rgb)
    if thisTrial != None:
        for paramName in thisTrial:
            exec('{} = thisTrial[paramName]'.format(paramName))
    
    # --- Prepare to start Routine "real" ---
    continueRoutine = True
    # update component parameters for each repeat
    sentence = trials['sentence']
    full_text = f"{names} {sentence}"
    text_7.setText(full_text)
    slider.reset()

  

(This is successful code)

How can I put the ‘John is happy’ sentence on the screen that I want?
Please help me, I’ve been doing this all day​:disappointed_relieved::disappointed_relieved::disappointed_relieved:

The text component should contain $name + ’ ’ + sentence (only one dollar)

name = ‘’ should be in Begin Experiment not Before Experiment

Or text2 = name + ’ ’ + sentence

Thank you😊