My experiment works perfectly well when running it locally via python.
I am trying to control a loop (“block”) in psychopy builder with a variable that is defined in a code component in “plan1” (the previous routine), which is outside the “block” loop - see below (rowsFromLearningBlock):
I have tried to use the window object (“window.rowsFromLearningBlock”) in order to make the variable global, but this hasn’t worked either. I have tried without the $ sign, but this also doesn’t work. The only solution I can see is duplicating the routines for each trial and discarding the current loops, in order to have a new conditions file with the correct rows defined for each one. However, I would rather not do this as there is a lot of trials.
I just tried this and got exactly the same error as the one I originally posted. It seems like the array still isn’t being recognised as valid. I’ve included a screenshot of the conditions file if it helps.
After the error occurs, doing console.log(rowsFromLearningBlock) returns “0:0” - is this where it is becoming invalid length? The intention is just to select the first row of the conditions file because later on, I want to select multiple rows.
I have tested inputting “0:0” in to the selected rows box and I get the same invalid length error, whereas I get no error when inputting “0:1”. I believe that this may be the source. Is there an alternative to just select the first row using this code?
Yep.
Since the last number in “0:0” or “0:1” is not included in the generated sequence of numbers you basically select no row in case of “0:0” (0:1 evalualtes to 0).
I assume if you entered for example 9 in the rowBlockEnd column of your condition file the 9th row should be included as well?
If that’s the case you could either change your condition file by adding 1 to every entry in the rowBlockEnd column or add 1 to the variable endB.