fixed FOR so it can take numbers entered as text

bug report by Kathy from Piazza
pull/89/head
jmoenig 2019-10-29 18:01:03 +01:00
rodzic d96b234c63
commit 40c416a121
2 zmienionych plików z 9 dodań i 5 usunięć

Wyświetl plik

@ -7,6 +7,7 @@
* optimized performance for sprite rendering and rotation
* added support for counting down using the "numbers" reporter
* **Notable Fixes:**
* fixed FOR so it can take numbers entered as text (bug report by Kathy from Piazza)
* removed "current" option from "switch to costume" block's drop-down menu
* **Translation Updates:**
@ -14,6 +15,7 @@
* threads: added support for counting down using the "numbers" reporter
* morphic: improved canvas recycling
* objects: optimized sprite rendering and rotating
* threads: FOR so it can take numbers entered as text (bug report by Kathy from Piazza)
### 2019-10-28
* new dev version

Wyświetl plik

@ -2220,15 +2220,17 @@ Process.prototype.doFor = function (upvar, start, end, script) {
var vars = this.context.outerContext.variables,
dta = this.context.accumulator;
if (dta === null) {
this.assertType(+start, 'number');
this.assertType(+end, 'number');
dta = this.context.accumulator = {
test : start < end ?
function () {return vars.getVar(upvar) > end; }
: function () {return vars.getVar(upvar) < end; },
step : start < end ? 1 : -1,
test : +start < +end ?
function () {return vars.getVar(upvar) > +end; }
: function () {return vars.getVar(upvar) < +end; },
step : +start < +end ? 1 : -1,
parms : new List() // empty parameters, reusable to avoid GC
};
vars.addVar(upvar);
vars.setVar(upvar, Math.floor(start));
vars.setVar(upvar, Math.floor(+start));
} else {
vars.changeVar(upvar, dta.step);
}