Skip to main content
My robot

Call a sub-routine

Call a sub-routine

Runs a sub-routine from the workspace and waits for it to finish before carrying on. It is how you reuse blocks of automation across robots, passing input data in and taking output data back.


Options


Sub-routine

The sub-routine to run. The list holds every sub-routine in the workspace except the current one (to prevent direct recursion). It has a search field to filter by name.

Advanced options

The sub-routine's inputs

The input fields the selected sub-routine defines. Each one matches an input configured in the Define the sub-routine's inputs action inside it. They take a fixed value, an action's output, code or a variable. This section only appears once a sub-routine is selected, and only if it has inputs defined.

Output actions

The output actions the sub-routine exposes through Exit the sub-routine. Each one needs a new local name to be referenced in the current designer. The name must not clash with any existing action identifier. This section only appears if the sub-routine has outputs of type Action.

Returns

The outputs are dynamic: they depend on what the Exit the sub-routine action inside the called sub-routine defines.

Javascript code

js
actions["action-id"]["field-name"] // the value the sub-routine returned (type set by the sub-routine)

Field selection

The selectable fields are generated automatically from the outputs configured in the sub-routine.

Rules and conditions

  • Sub-routine is required in every version.
  • In version 3.0, every required input field of the sub-routine has to be filled in before you can save.
  • In version 3.0, every listed output action needs a local name — the save button stays blocked until they all have one.
  • In version 3.0, each output action's local name has to be unique within the current designer.
  • In version 3.0, the inputs and outputs load automatically when you select the sub-routine — wait for them before configuring the fields.
  • In versions 1.0 and 2.0, Arguments is optional and has to contain code that evaluates to a valid JavaScript object.