URL of experiment: https://pavlovia.org/visionlab_illinois/vs_template
Description of the problem:
I am trying to pass a variable as an argument in a function that goes into the scheduler. However, it seems that the argument is not being read as a variable, and is undefined instead. Here’s the error message I get:
TypeError: right-hand side of 'in' should be an object, got undefined
The error occurs in the consentRoutineBegin function (I have made a comment below).
Here are bits and pieces of my code that are relevant to this error.
flowScheduler.add(updateInfo);
flowScheduler.add(consentRoutineBegin('consentImg1'));
var consentImg1;
function experimentInit() {
consentImg1 = new visual.ImageStim({
win: psychoJS.window,
name: 'consentImg1',
image: '05550_online_consent_form_pg1.png'
});
// Routine for consent page 1
var t;
var frameN;
var consent1Components;
function consentRoutineBegin(img) {
return function (img) {
//------Prepare to start Routine 'instruct'-------
psychoJS.window.adjustScreenSize(); // make window fullsize again because the download will exit fullscreen
t = 0;
consentClock.reset(); // clock
frameN = -1;
// update component parameters for each repeat
ready.keys = undefined;
ready.rt = undefined;
// keep track of which components have finished
consentComponents = [];
consentComponents.push(img);
consentComponents.push(ready);
for (const thisComponent of consentComponents)
if ('status' in thisComponent) // <- here's the error
thisComponent.status = PsychoJS.Status.NOT_STARTED;
return Scheduler.Event.NEXT;
};
}
I know that consentImg1 is defined because if I call it directly instead of passing it as an argument (i.e. replace img
with consentImg1
), it works. It seems that the problem is passing an object as a function.
Thanks in advance!