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=='#') {
// check for parameter
ctype += tlen;
if (*ctype=='(' && *(lp+tlen)=='(') {
char nxttok = '(';
char *argptr = ctype+tlen;
lp += tlen;
do {
if (*ctype==nxttok && *lp==nxttok) {
float fparam;
numeric = 1;
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) {
// was string, not number
numeric = 0;
// get the string
GetStringArgument((char*)ctype + 1, OPER_EQU, cmpstr, 0);
argptr = GetStringArgument((char*)ctype + 1, OPER_EQU, cmpstr, 0);
}
lp += tlen;
if (*lp=='(') {
if (*lp==nxttok) {
// fetch destination
lp++;
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 {
lp += tlen;
if (*ctype=='(' || (*lp!=SCRIPT_EOL && *lp!='?')) {
if (*ctype==nxttok || (*lp!=SCRIPT_EOL && *lp!='?')) {
// revert
section = 0;
}
}
nxttok = ' ';
ctype = argptr;
} while (*lp==' ' && (section == 1) );
}
}
}