Merge pull request #10525 from jig432/development

Added support for multiple arguments to a script subroutine.
This commit is contained in:
Theo Arends 2021-01-12 10:14:12 +01:00 committed by GitHub
commit 00b8f2aaed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4550,19 +4550,23 @@ int16_t Run_script_sub(const char *type, int8_t tlen, JsonParserObject *jo) {
if (*ctype=='#') { if (*ctype=='#') {
// check for parameter // check for parameter
ctype += tlen; ctype += tlen;
if (*ctype=='(' && *(lp+tlen)=='(') { char nxttok = '(';
char *argptr = ctype+tlen;
lp += tlen;
do {
if (*ctype==nxttok && *lp==nxttok) {
float fparam; float fparam;
numeric = 1; numeric = 1;
glob_script_mem.glob_error = 0; glob_script_mem.glob_error = 0;
GetNumericArgument((char*)ctype, OPER_EQU, &fparam, 0); argptr = GetNumericArgument((char*)ctype + 1, OPER_EQU, &fparam, 0);
if (glob_script_mem.glob_error==1) { if (glob_script_mem.glob_error==1) {
// was string, not number // was string, not number
numeric = 0; numeric = 0;
// get the string // get the string
GetStringArgument((char*)ctype + 1, OPER_EQU, cmpstr, 0); argptr = GetStringArgument((char*)ctype + 1, OPER_EQU, cmpstr, 0);
} }
lp += tlen; if (*lp==nxttok) {
if (*lp=='(') {
// fetch destination // fetch destination
lp++; lp++;
lp = isvar(lp, &vtype, &ind, 0, 0, 0); lp = isvar(lp, &vtype, &ind, 0, 0, 0);
@ -4591,12 +4595,14 @@ int16_t Run_script_sub(const char *type, int8_t tlen, JsonParserObject *jo) {
} }
} }
} else { } else {
lp += tlen; if (*ctype==nxttok || (*lp!=SCRIPT_EOL && *lp!='?')) {
if (*ctype=='(' || (*lp!=SCRIPT_EOL && *lp!='?')) {
// revert // revert
section = 0; section = 0;
} }
} }
nxttok = ' ';
ctype = argptr;
} while (*lp==' ' && (section == 1) );
} }
} }
} }