From 5e565d10f669ee5f7c2ed5f9a67c36809d922704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20M=C3=B6nig?= Date: Sat, 25 Jan 2025 01:30:09 +0100 Subject: [PATCH] fixed evaluating special strings inside numerical input slots --- HISTORY.md | 8 ++++++++ snap.html | 4 ++-- src/blocks.js | 14 ++++++++++---- src/gui.js | 4 ++-- sw.js | 2 +- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 360d141e10..f8ce7c3b31 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,6 +2,14 @@ ## in development: +## 10.4.5: +* **Notable Fixes:** + * fixed evaluating special strings inside numerical input slots + +### 2025-01-25 +* blocks: fixed evaluating special strings inside numerical input slots +* prepared v10.4.5 patch + ## 10.4.4: * **Notable Fixes:** * fixed alphanumeric input slot evaluation for list accessors diff --git a/snap.html b/snap.html index 0ea2eb7014..42202bc566 100755 --- a/snap.html +++ b/snap.html @@ -16,11 +16,11 @@ - + - + diff --git a/src/blocks.js b/src/blocks.js index 45b18631b3..6f4c6d1199 100644 --- a/src/blocks.js +++ b/src/blocks.js @@ -162,7 +162,7 @@ CustomHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2025-January-24'; +modules.blocks = '2025-January-25'; var SyntaxElementMorph; var BlockMorph; @@ -12334,8 +12334,11 @@ InputSlotMorph.prototype.mappedCode = function () { InputSlotMorph.prototype.evaluate = function () { // answer my contents, which can be a "wish", i.e. a block that refers to - // another sprite's local method, or a text string. - var val; + // another sprite's local method, or a text string. If I am numerical + // convert that string to a number. If the conversion fails answer the + // string (e.g. for special choices like 'random', 'all' or 'last') + // otherwise the numerical value. + var val, num; if (this.selectedBlock) { return this.selectedBlock; } @@ -12353,7 +12356,10 @@ InputSlotMorph.prototype.evaluate = function () { !this.isAlphanumeric && (!this.evaluateAsString || val === '') ) { - return +val; + num = +val; + if (!isNaN(num)) { + return num; + } } return val; }; diff --git a/src/gui.js b/src/gui.js index 7cf5c31385..868a8d7097 100644 --- a/src/gui.js +++ b/src/gui.js @@ -87,11 +87,11 @@ HatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2025-January-24'; +modules.gui = '2025-January-25'; // Declarations -var SnapVersion = '10.4.4'; +var SnapVersion = '10.4.5'; var IDE_Morph; var ProjectDialogMorph; diff --git a/sw.js b/sw.js index 67a65a06a0..2750833e53 100644 --- a/sw.js +++ b/sw.js @@ -1,6 +1,6 @@ /*global self, caches*/ /*jshint esversion: 6*/ -var snapVersion = '10.4.4', +var snapVersion = '10.4.5', cacheName = `snap-pwa-${snapVersion}`, filesToCache = [ 'snap.html',