mirror of
https://github.com/arendst/Tasmota.git
synced 2025-04-24 23:07:17 +00:00
Merge pull request #10525 from jig432/development
Added support for multiple arguments to a script subroutine.
This commit is contained in:
commit
00b8f2aaed
@ -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) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user