Using a variable file name for Conditions file of a loop

I have switched to 2021.1.2 and now my use of a variable descriptor for the conditions file in a loop is not acceptable. I want to indicate any of three files, which I had done with ‘trialsPearce’+$condord+’.xlsx’, where $condord was a variable in another file that had 3 values. That worked with PsychoPy3 2020, but PsychoPy now does not want a file name in quotes. How do I create a variable file name?

1 Like

@bwhitlow , have you tried

$"trialsPearce" + condord + ".xlsx" 

Hi David,

I have not tried that - which partly reflects my lack of a full understanding of the “$” symbol.

However, I was able to get it work by a 2-step coding process of Acond=condord, then Afile=“trialsPearce”+str(Acond)+".xlsx" and putting $Afile in the Conditions for the trials. But I will try your suggestion as well.

RIght now I’m having trouble with JS accepting the use of “expInfo” to get the condition designation when I migrate to Pavlovia.



@bwhitlow , $ it means to treat the entry as code. Something like the following in the loop “Conditions” entry should translate ok to JS, which would create something like "conditionA.xlsx":

$"condition" + expInfo['myCondition'] + ".xlsx"

Is ‘myCondition’ the name of the field in expInfo, so the entry is what gets added to the string?

Okay, I see that it is. Thanks!

But now the effort to synch on Pavlovia crashes because expInfo is not recognized. Any thoughts on that.?

Where are you using expInfo?

I was using it in the kind of expression you suggested, but now I see that I have been mis-reading the Traceback call error box, and I will have to clarify what is causing the crash. Sorry about that.