fix(core.gbapp): Fixing array base in BASIC.

This commit is contained in:
Rodrigo Rodriguez 2020-11-12 15:31:05 -03:00
parent 66a51d5c89
commit 91002d1bac

View file

@ -292,15 +292,16 @@ class SysClass {
} }
} }
// As BASIC uses arrays starting with 1 (one) as index,
// a ghost element is added at 0 (zero) position.
let array = []; let array = [];
array.push({}); array.push({ 'this is a base 1': 'array' });
let foundIndex = 0; let foundIndex = 0;
for (; foundIndex < results.text.length; foundIndex++) { for (; foundIndex < results.text.length; foundIndex++) {
// Filter results action. // Filter results action.
if (results.text[foundIndex][columnIndex].toLowerCase() === value.toLowerCase()) { if (results.text[foundIndex][columnIndex].toLowerCase() === value.toLowerCase()) {
let output = {}; let output = {};
const row = results.text[foundIndex]; const row = results.text[foundIndex];
for (let colIndex = 0; colIndex < row.length; colIndex++) { for (let colIndex = 0; colIndex < row.length; colIndex++) {
@ -311,12 +312,12 @@ class SysClass {
} }
} }
if (array.length === 0) { if (array.length === 1) {
GBLog.info(`BASIC: FIND the data set is empty.`); GBLog.info(`BASIC: FIND the data set is empty.`);
return null; return null;
} else if (array.length === 1) { } else if (array.length === 2) {
GBLog.info(`BASIC: FIND single result: ${array[0]}.`); GBLog.info(`BASIC: FIND single result: ${array[0]}.`);
return array[0]; return array[1];
} else { } else {
GBLog.info(`BASIC: FIND multiple result count: ${array.length}.`); GBLog.info(`BASIC: FIND multiple result count: ${array.length}.`);
return array; return array;