Skip to content

Commit 3f7dbf6

Browse files
committed
Clarified subroutine parameter requirements and behavior.
Added description of multiple parameter subroutines.
1 parent 77d746a commit 3f7dbf6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

docs/Scripting-Language.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,14 @@ A Tasmota MQTT RESULT message invokes the script's `E` section. Add `print` stat
514514
`hsvrgb(h s v)` converts hue (0..360), saturation (0..100) and value (0..100) to RGB color
515515
`dt` display text command (if #define USE_DISPLAY)
516516

517+
**Subroutines and Parameters**
517518
`#name` names a subroutine. Subroutine is called with `=#name`
518-
`#name(param)` names a subroutine with a parameter. Subroutine is called with `=#name(param)`
519-
Subroutines end with the next `#` or `>` line or break. Subroutines may be nested
519+
`#name(param)` names a subroutine with a parameter.
520+
Each parameter variable must be declared in the '>D' section.
521+
A subroutine with multiple parameters is declared as '#name(p1 p2 p3)', i.e. spaces between parameters.
522+
A subroutine is invoked with `=#name(param)` or '=#name(p1 p2)
523+
Invoking a subroutine sets the parameter variable to the corresponding expression of the invocation. This means that parameter variables have script wide scope, i.e. they are not local variables to the subroutine.
524+
Subroutines end with the next `#` or `>` line or break. Subroutine invocations may be nested.
520525
Parameters can be numbers or strings and on type mismatch are converted
521526

522527
If `#define USE_SCRIPT_SUB_COMMAND` is included in your `user_config_override.h`, a subroutine may be invoked via the Console or MQTT using the subroutine's name. For example, a declared subroutine `#SETLED(num)` may be invoked by typing `SETLED 1` in the Console. The parameter `1` is passed into the `num` argument. This also works with string parameters.

0 commit comments

Comments
 (0)