OS: Ubuntu Linux, v16.04
PsychoPy: 3.1.4
javascript variables won’t persist
URL of experiment: https://run.pavlovia.org/RobinScaife/openiat/html/
Description of the problem:
This is to make an Implicit Association Test (which we previously had working in old PsychoPy) work online with Pavlovia. I can’t seem to refer to js variables defined in an initial block from a subsequent block
In SetupCode block I have JS code (under ‘begin experiment’):
`trainlabelsL=['A = \nWhite','A = \nBlack'];`
later (after some instructions and a short practice), I have the main experiment, controlled by ‘superloop’ and which begins with a block Superloop_code which is intended to declare the variables for each loop based on the loop count. Under ‘begin routine’ I have this JS
`trainlabelL=trainlabelsL[superloop.thisRepN];`
Later on, in the block Training2, $trainlabelL is used in a text display block.
However, there are two issues with making this work
-
The array trainlabelsL is not recognised. Although I tried to define it in SetupCode, by the time we get to Superloop_code it seems to have been forgotten (or I am calling it wrong)
-
The way I index the number of reptitions (superloop.thisRepN) doesn’t work - I assume psychopy isn’t creating this variable for the loop count. So which variable name should I use?
In Superloop_code I ‘hard code’ the variables’ and make everything run, so I’m pretty sure it is just my variables and their indexing I have an issue with
`trainlabelL=['A = \nWhite','A = \nBlack'][0]`
If you run the only experiment you will see, when you get to the training block, that the top left label is missing, while the top right label is there (but only because I hard coded its value)