Skip to content

Commit ae20cb1

Browse files
committed
BF: beginRoutineJS code was broekn if continueRoutine==False
The output tried to return early (as if in the eachFrame block) whereas what it should have done was store continueRoutine as a global. Key changes -------------- 1. Set continueRoutine as a global at *top* of beginRoutine code block so it can be modified later in that block 2. remove this line from eachFrame (it would undo above fix) let continueRoutine = true; // until we're told otherwise 3. remove the erroneous code where the return Scheduler.Event.NEXT was made dependent on continueRoutine
1 parent 817ed9e commit ae20cb1

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

psychopy/experiment/routine.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,9 @@ def writeRoutineBeginCodeJS(self, buff, modular):
270270
code = ("//------Prepare to start Routine '%(name)s'-------\n"
271271
"t = 0;\n"
272272
"%(name)sClock.reset(); // clock\n"
273-
"frameN = -1;\n" % self.params)
273+
"frameN = -1;\n"
274+
"continueRoutine = true; // until we're told otherwise\n"
275+
% self.params)
274276
buff.writeIndentedLines(code)
275277
# can we use non-slip timing?
276278
maxTime, useNonSlip = self.getMaxTime()
@@ -304,15 +306,11 @@ def writeRoutineBeginCodeJS(self, buff, modular):
304306
buff.writeIndentedLines(code)
305307

306308
# are we done yet?
307-
code = ("// check if the Routine should terminate\n"
308-
"if (!continueRoutine) {"
309-
" // a component has requested a forced-end of Routine\n"
310-
" return Scheduler.Event.NEXT;\n"
311-
"}\n")
309+
code = ("return Scheduler.Event.NEXT;\n")
312310
buff.writeIndentedLines(code)
313311

314312
buff.setIndentLevel(-1, relative=True)
315-
buff.writeIndentedLines("};\n")
313+
buff.writeIndentedLines("}\n")
316314
buff.setIndentLevel(-1, relative=True)
317315
buff.writeIndentedLines("}\n")
318316

@@ -329,7 +327,6 @@ def writeEachFrameCodeJS(self, buff, modular):
329327
buff.setIndentLevel(1, relative=True)
330328

331329
code = ("//------Loop for each frame of Routine '%(name)s'-------\n"
332-
"let continueRoutine = true; // until we're told otherwise\n"
333330
"// get current time\n"
334331
"t = %(name)sClock.getTime();\n"
335332
"frameN = frameN + 1;"

psychopy/tests/data/correctScript/js/correctTextComponent.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ function trialRoutineBegin() {
102102
trialClock.reset(); // clock
103103
frameN = -1;
104104
routineTimer.add(1.000000);
105+
105106
// update component parameters for each repeat
106107
// keep track of which components have finished
107108
trialComponents = [];
@@ -118,7 +119,7 @@ var frameRemains;
118119
var continueRoutine;
119120
function trialRoutineEachFrame() {
120121
//------Loop for each frame of Routine 'trial'-------
121-
let continueRoutine = true; // until we're told otherwise
122+
122123
// get current time
123124
t = trialClock.getTime();
124125
frameN = frameN + 1;// number of completed frames (so 0 is the first frame)

0 commit comments

Comments
 (0)