Create a message within a loop

Hi,

I have a loop with 200 trials. The loop is called trials_1. I want to present a notification every 50 trials. So I include a code component:

Blockquote
Each frame

if not trials_1.thisN in [50]: # on most trials:
continueRoutine = False # don’t even start this routine
else:
print(trials_1.thisN)

I translate this code to run the experiment online:

var _pj;
function _pj_snippets(container) {
function in_es6(left, right) {
if (((right instanceof Array) || ((typeof right) === “string”))) {
return (right.indexOf(left) > (- 1));
} else {
if (((right instanceof Map) || (right instanceof Set) || (right instanceof WeakMap) || (right instanceof WeakSet))) {
return right.has(left);
} else {
return (left in right);
}
}
}
container[“in_es6”] = in_es6;
return container;
}
_pj = {};
_pj_snippets(_pj);
if ((! _pj.in_es6(trials_1.thisN, [61]))) {
continueRoutine = false;
} else {
console.log(trials_1.thisN);
}

But it is not working: the message does not appear. At the same time, there is no error message. I have another loop, called “trials” (instead of “trials_1”), and my code works with this loop perfectly and online as well.

Hi Marina, where would you like the message to appear?

Hi Thomas,

It should appear after every 50 trials in the middle of the screen.

I mean that the loop continues to the end (all 200 trials) and my pause message which should appear after every 50 trials never appears.

Thanks for the update! It’s a bit difficult for me to establish which parts of your code are intended to achieve what you’re after, so I’d recommend to log information to see what happens via console.log. For example:
trials_1.thisN // To check whether thisN has the right value
! _pj.in_es6(trials_1.thisN, [61] // To check of the expression in your if statement works out

And maybe try out the part that you expect to show the pause message to see if that works