mirror of
https://github.com/inexorabletash/jsbasic.git
synced 2024-05-28 22:41:34 +00:00
Fix ON GOTO and ON GOSUB better - Should handle edge cases
This commit is contained in:
parent
29e8b8ec70
commit
42eca47f96
6
basic.js
6
basic.js
|
@ -523,10 +523,11 @@ this.basic = (function() {
|
||||||
},
|
},
|
||||||
|
|
||||||
'on_goto': function ON_GOTO(index /* , ...lines */) {
|
'on_goto': function ON_GOTO(index /* , ...lines */) {
|
||||||
|
index = Math.floor(index)
|
||||||
if (index < 0 || index > 255) {
|
if (index < 0 || index > 255) {
|
||||||
runtime_error(ERRORS.ILLEGAL_QUANTITY);
|
runtime_error(ERRORS.ILLEGAL_QUANTITY);
|
||||||
}
|
}
|
||||||
index = (index - 1) >> 0;
|
--index;
|
||||||
var lines = Array.prototype.slice.call(arguments, 1);
|
var lines = Array.prototype.slice.call(arguments, 1);
|
||||||
|
|
||||||
if (index >= 0 && index < lines.length) {
|
if (index >= 0 && index < lines.length) {
|
||||||
|
@ -543,10 +544,11 @@ this.basic = (function() {
|
||||||
},
|
},
|
||||||
|
|
||||||
'on_gosub': function ON_GOSUB(index /* , ...lines */) {
|
'on_gosub': function ON_GOSUB(index /* , ...lines */) {
|
||||||
|
index = Math.floor(index)
|
||||||
if (index < 0 || index > 255) {
|
if (index < 0 || index > 255) {
|
||||||
runtime_error(ERRORS.ILLEGAL_QUANTITY);
|
runtime_error(ERRORS.ILLEGAL_QUANTITY);
|
||||||
}
|
}
|
||||||
index = (index - 1) >> 0;
|
--index;
|
||||||
var lines = Array.prototype.slice.call(arguments, 1);
|
var lines = Array.prototype.slice.call(arguments, 1);
|
||||||
if (index >= 0 && index < lines.length) {
|
if (index >= 0 && index < lines.length) {
|
||||||
state.stack.push({
|
state.stack.push({
|
||||||
|
|
Loading…
Reference in New Issue
Block a user