Fix ON GOTO and ON GOSUB - Should resolve #11
This commit is contained in:
parent
26bb151874
commit
29e8b8ec70
26
basic.js
26
basic.js
|
@ -523,13 +523,15 @@ this.basic = (function() {
|
|||
},
|
||||
|
||||
'on_goto': function ON_GOTO(index /* , ...lines */) {
|
||||
if (index < 0 || index > 255) {
|
||||
runtime_error(ERRORS.ILLEGAL_QUANTITY);
|
||||
}
|
||||
index = (index - 1) >> 0;
|
||||
var lines = Array.prototype.slice.call(arguments, 1);
|
||||
|
||||
if (index < 0 || index >= lines.length) {
|
||||
runtime_error(ERRORS.ILLEGAL_QUANTITY);
|
||||
if (index >= 0 && index < lines.length) {
|
||||
throw new GoToLine(lines[index]);
|
||||
}
|
||||
throw new GoToLine(lines[index]);
|
||||
},
|
||||
|
||||
'gosub': function GOSUB(line) {
|
||||
|
@ -541,16 +543,18 @@ this.basic = (function() {
|
|||
},
|
||||
|
||||
'on_gosub': function ON_GOSUB(index /* , ...lines */) {
|
||||
index = (index - 1) >> 0;
|
||||
var lines = Array.prototype.slice.call(arguments, 1);
|
||||
if (index < 0 || index >= lines.length) {
|
||||
if (index < 0 || index > 255) {
|
||||
runtime_error(ERRORS.ILLEGAL_QUANTITY);
|
||||
}
|
||||
state.stack.push({
|
||||
gosub_return: state.stmt_index,
|
||||
line_number: state.line_number
|
||||
});
|
||||
throw new GoToLine(lines[index]);
|
||||
index = (index - 1) >> 0;
|
||||
var lines = Array.prototype.slice.call(arguments, 1);
|
||||
if (index >= 0 && index < lines.length) {
|
||||
state.stack.push({
|
||||
gosub_return: state.stmt_index,
|
||||
line_number: state.line_number
|
||||
});
|
||||
throw new GoToLine(lines[index]);
|
||||
}
|
||||
},
|
||||
|
||||
'return': function RETURN() {
|
||||
|
|
Loading…
Reference in New Issue