Skip to content

Return ​

Purpose: end a subroutine and go back to the step after the Call, optionally with a return value.

Return settings

Return only appears in the Add Step list while you edit a subroutine. Value is the return value (expression allowed, optional).

JSON ​

json
{ "return": { "value": "${x} * 2" } }
{ "return": true }
FormMeaning
{"return": {"value": expression}}Return a value
{"return": true} or {"return": {}}Just return, without a value

A subroutine also returns by itself after its last step, but without a value.

Result ​

Return itself is PASS, and the Actual column shows returns value. If the Call has store but the subroutine returns without a value, the round stops and is judged FAIL (returned no value for ...).

Example ​

SubroutineWhat it doesResult
doubleReturns ${x} * 2double(21) = 42
clampReturns 100 early when x > 100, otherwise returns xclamp(250) = 100

Return example result

Notes ​

  • A Return inside an If ends the subroutine early (clamp in the example).
  • A script with Return in a case does not load.

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.

Roach Modbus Tool by Mr.Roach