fix(basic.gblib): FIND now has an in-line not found message option.
This commit is contained in:
parent
d2b0a2073b
commit
584ed55f5c
2 changed files with 30 additions and 0 deletions
|
@ -220,6 +220,18 @@ export class GBVMService extends GBService {
|
||||||
return `${$2} = hear()`;
|
return `${$2} = hear()`;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
code = code.replace(/(\w)\s*\=\s*find\s*(.*)\s*or talk\s*(.*)/gi, ($0, $1, $2, $3) => {
|
||||||
|
return `${$1} = sys().find(${$2})\n
|
||||||
|
if (!${$1}) {
|
||||||
|
if (resolve){
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
talk (${$3})\n;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
});
|
||||||
|
|
||||||
code = code.replace(/(\w)\s*\=\s*find\s*(.*)/gi, ($0, $1, $2, $3) => {
|
code = code.replace(/(\w)\s*\=\s*find\s*(.*)/gi, ($0, $1, $2, $3) => {
|
||||||
return `${$1} = sys().find(${$2})\n`;
|
return `${$1} = sys().find(${$2})\n`;
|
||||||
});
|
});
|
||||||
|
|
|
@ -265,6 +265,24 @@ export class SystemKeywords {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds a value or multi-value results in a tabular file.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* rows = FIND "file.xlsx", "A2=active" WHEN NOT FOUND TALK ""
|
||||||
|
* i = 1
|
||||||
|
* do while i < ubound(row)
|
||||||
|
* row = rows[i]
|
||||||
|
* send sms to "+" + row.mobile, "Hello " + row.namee + "! "
|
||||||
|
* loop
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public async findWithExit(file: string, talk, ...args): Promise<any> {
|
||||||
|
this.find(file, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds a value or multi-value results in a tabular file.
|
* Finds a value or multi-value results in a tabular file.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue