Builder does not save variable on each routine

OS: macOS 10.13.6
PsychoPy version: 3.0.0b12
Standard Standalone? (y/n): y
What are you trying to achieve?: Save a variable on each trial

What did you try to make it work?: Working in Builder. Defined the variable at start of exp. Checked the boxes to save it at start and end of experiment and at start and end of each routine.

What specifically went wrong when you tried that?: The .csv file has the values at start and end of the experiment but not for each trial.

I can switch to coder and add this line
trials.addData(‘trials.var1’, var1)
within the code for a trial. But why doesn’t Builder put that line there?

Hi,
where exactly did you define the variable and check those boxes? If you put var1 = 0 in the Begin Experiment tab and thisExp.addData(‘trials.var1’, var1) in the End Routine tab of your code component within a loop called trials, it should work.

Edit after the post below: I meant to write thisExp.addData, too, not trials.addData like in your question.

@markusmeister, have you tried

thisExp.addData("trials.var1", var1)