Added support for multiple arguments to a subroutine.

This commit is contained in:
JohnG 2021-01-11 20:12:46 -08:00
parent 4e5e3d419b
commit 0d81ffe30b

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) );
} }
} }
} }