From 42eca47f965134138f05b571565d99b2b40c110f Mon Sep 17 00:00:00 2001 From: Sigurdur Sveinn Halldorsson Date: Wed, 20 Jul 2016 20:21:11 +0200 Subject: [PATCH] Fix ON GOTO and ON GOSUB better - Should handle edge cases --- basic.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/basic.js b/basic.js index 537f446..0debd3c 100644 --- a/basic.js +++ b/basic.js @@ -523,10 +523,11 @@ this.basic = (function() { }, 'on_goto': function ON_GOTO(index /* , ...lines */) { + index = Math.floor(index) if (index < 0 || index > 255) { runtime_error(ERRORS.ILLEGAL_QUANTITY); } - index = (index - 1) >> 0; + --index; var lines = Array.prototype.slice.call(arguments, 1); if (index >= 0 && index < lines.length) { @@ -543,10 +544,11 @@ this.basic = (function() { }, 'on_gosub': function ON_GOSUB(index /* , ...lines */) { + index = Math.floor(index) if (index < 0 || index > 255) { runtime_error(ERRORS.ILLEGAL_QUANTITY); } - index = (index - 1) >> 0; + --index; var lines = Array.prototype.slice.call(arguments, 1); if (index >= 0 && index < lines.length) { state.stack.push({