Call
Purpose: run a subroutine and come back to the next step, optionally passing parameters and receiving a return value.

After you pick the subroutine to call, its parameters are listed below; fill in a value for each. Save result to is the variable that receives the return value (optional).
JSON
{ "call": { "sub": "read_sum", "args": { "addr": "0x0700" }, "store": "total" } }| Field | Required | Meaning |
|---|---|---|
sub | Yes | Subroutine name |
args | No | Parameter values, {"parameter": value}. Values can be expressions, worked out with the caller's variables. Parameters without a default must be passed |
store | No | Variable that receives the value from Return |
Result
| Result | When |
|---|---|
| PASS | No step in the subroutine FAILs. With store, the Actual column shows the value received |
| FAIL | A step in the subroutine FAILs, or store is given but the subroutine returns no value |
If communication fails inside the subroutine under on_error: skip, the rest of the calling case is skipped too.
Example
read_sum first calls another subroutine, fill, to write 1, 2 and 3, then reads the 3 registers back and returns their sum. The case receives it with store: "total", and the Log prints Sum of 0x0700..0x0702 = 6.

Notes
- Passing a parameter the subroutine does not have, or leaving out one without a default, stops the script from loading, and the error names the parameter.
- A Call takes up to 8 parameters.
Download the sample script
Sample script
Before running it, start a Slave window on 127.0.0.1:502 and click Listen, then open the script with Open JSON in Script mode and click Run. See How to use the examples.
