fix(basic.gblib): Trying to find invalid cell value on .xlsx being filtered.
This commit is contained in:
parent
44a221b07c
commit
3f0b020155
1 changed files with 18 additions and 15 deletions
|
@ -290,14 +290,14 @@ export class SystemKeywords {
|
||||||
* loop
|
* loop
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public async find(file: string, ...args ): Promise<any> {
|
public async find(file: string, ...args): Promise<any> {
|
||||||
GBLog.info(`BASIC: FIND running on ${file}...`);
|
GBLog.info(`BASIC: FIND running on ${file} and args: ${JSON.stringify(args)}...`);
|
||||||
let [baseUrl, client] = await this.internalGetDriveClient();
|
let [baseUrl, client] = await this.internalGetDriveClient();
|
||||||
const botId = this.min.instance.botId;
|
const botId = this.min.instance.botId;
|
||||||
const path = `/${botId}.gbai/${botId}.gbdata`;
|
const path = `/${botId}.gbai/${botId}.gbdata`;
|
||||||
|
|
||||||
let document = await this.internalGetDocument(client, baseUrl, path, file);
|
let document = await this.internalGetDocument(client, baseUrl, path, file);
|
||||||
|
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
throw `File '${file}' has a FIND call with more than 1 arguments. Check the .gbdialog associated.`;
|
throw `File '${file}' has a FIND call with more than 1 arguments. Check the .gbdialog associated.`;
|
||||||
}
|
}
|
||||||
|
@ -308,18 +308,21 @@ export class SystemKeywords {
|
||||||
const columnName = filter[0];
|
const columnName = filter[0];
|
||||||
const value = filter[1];
|
const value = filter[1];
|
||||||
let sheets = await client
|
let sheets = await client
|
||||||
.api(`${baseUrl}/drive/items/${document.id}/workbook/worksheets`)
|
.api(`${baseUrl}/drive/items/${document.id}/workbook/worksheets`)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
let results = await client
|
let results = await client
|
||||||
.api(`${baseUrl}/drive/items/${document.id}/workbook/worksheets('${sheets.value[0].name}')/range(address='A1:Z100')`)
|
.api(`${baseUrl}/drive/items/${document.id}/workbook/worksheets('${sheets.value[0].name}')/range(address='A1:Z100')`)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
// Increments columnIndex by looping until find a column match.
|
// Increments columnIndex by looping until find a column match.
|
||||||
|
|
||||||
let columnIndex = 0;
|
let columnIndex = 0;
|
||||||
const header = results.text[0];
|
const header = results.text[0];
|
||||||
for (; columnIndex < header.length; columnIndex++) {
|
for (; columnIndex < header.length; columnIndex++) {
|
||||||
|
|
||||||
|
GBLog.info(`FIND DEBUG header: ${header[columnIndex]} columnName: ${columnName}`);
|
||||||
|
|
||||||
if (header[columnIndex].toLowerCase() === columnName.toLowerCase()) {
|
if (header[columnIndex].toLowerCase() === columnName.toLowerCase()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -327,19 +330,19 @@ export class SystemKeywords {
|
||||||
|
|
||||||
// As BASIC uses arrays starting with 1 (one) as index,
|
// As BASIC uses arrays starting with 1 (one) as index,
|
||||||
// a ghost element is added at 0 (zero) position.
|
// a ghost element is added at 0 (zero) position.
|
||||||
|
|
||||||
let table = [];
|
let table = [];
|
||||||
table.push({ 'this is a hidden base 0': 'element' });
|
table.push({ 'this is a hidden base 0': 'element' });
|
||||||
let foundIndex = 0;
|
let foundIndex = 0;
|
||||||
|
|
||||||
// Fills the row variable.
|
// Fills the row variable.
|
||||||
|
|
||||||
for (; foundIndex < results.text.length; foundIndex++) {
|
for (; foundIndex < results.text.length; foundIndex++) {
|
||||||
|
|
||||||
let result = results.text[foundIndex][columnIndex];
|
let result = results.text[foundIndex][columnIndex];
|
||||||
|
|
||||||
GBLog.info(`FIND DEBUG result on foundIndex: ${foundIndex} columnIndex: ${columnIndex}: ${result}`);
|
GBLog.info(`FIND DEBUG result on foundIndex: ${foundIndex} columnIndex: ${columnIndex}: ${result}`);
|
||||||
|
|
||||||
// Filter results action.
|
// Filter results action.
|
||||||
|
|
||||||
if (result && result.toLowerCase() === value.toLowerCase()) {
|
if (result && result.toLowerCase() === value.toLowerCase()) {
|
||||||
|
@ -557,7 +560,7 @@ export class SystemKeywords {
|
||||||
`${baseUrl}/drive/root:/${root}`)
|
`${baseUrl}/drive/root:/${root}`)
|
||||||
.get();
|
.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Performs the conversion operation getting a reference
|
// Performs the conversion operation getting a reference
|
||||||
// to the source and calling /content on drive API.
|
// to the source and calling /content on drive API.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue