new(basic.gblib): new TOLIST and FIND now works with hour intervals.

This commit is contained in:
Rodrigo Rodriguez 2021-08-05 17:19:24 -03:00
parent 6eb1f4d2aa
commit babf043eb3
2 changed files with 11 additions and 7 deletions

View file

@ -80,7 +80,7 @@ export class GBVMService extends GBService {
const vbsFile = filename.substr(0, filename.indexOf('docx')) + 'vbs';
const fullVbsFile = urlJoin(folder, vbsFile);
const docxStat = fs.statSync(urlJoin(folder, wordFile));
const interval = 30000; // If compiled is older 30 seconds, then recompile.
const interval = 1000; // If compiled is older 30 seconds, then recompile.
let writeVBS = true;
if (fs.existsSync(fullVbsFile)) {
const vbsStat = fs.statSync(fullVbsFile);
@ -502,7 +502,8 @@ export class GBVMService extends GBService {
code = code.replace('hour = await', 'hour ='); // TODO: Improve this.
code = code.replace('weekday = await', 'weekday ='); // TODO: Improve this.
code = code.replace('tolist = await', 'tolist ='); // TODO: Improve this.
code = code.replace('isArray = async', 'isArray ='); // TODO: Waiting for a compiler.
code = code.replace('isarray = async', 'isarray ='); // TODO: Waiting for a compiler.
code = code.replace('isArray = async', 'isarray ='); // TODO: Waiting for a compiler.
return code;
}
@ -788,7 +789,7 @@ export class GBVMService extends GBService {
ret = await sandbox[mainMethod](step);
} catch (error) {
throw new Error(`BASIC ERROR: ${error.message} ${error.stack}`);
throw new Error(`BASIC ERROR: ${error.message ? error.message : error}\n Stack:${error.stack}`);
}
return ret;
}

View file

@ -75,11 +75,14 @@ export class SystemKeywords {
}
public async append(...args) {
return [].concat(...args);
let array = [].concat(...args);
return array.filter(function (item, pos) { return item; });
}
public async sortBy(array, memberName) {
return array ? [].sort(p => p[memberName]) : null;
return array ? array.sort(p =>
{ if (p) { return p[memberName]; } }) :
null;
}
/**
@ -312,7 +315,7 @@ export class SystemKeywords {
let getFilter = async (text) => {
let filter;
const operators = [/\<\=/, /\>\=/, /\</, /\>/, /\bnot in\b/,/\bin\b/, /\=/];
const operators = [/\<\=/, /\>\=/, /\</, /\>/, /\bnot in\b/, /\bin\b/, /\=/];
let done = false;
await CollectionUtil.asyncForEach(operators, async op => {
var re = new RegExp(op, "gi");
@ -350,7 +353,7 @@ export class SystemKeywords {
function isValidNumber(number) {
return !isNaN(number);
}
function isValidHour(value) {
return /^([01]?[0-9]|2[0-3]):[0-5][0-9]$/.test(value);
}