Skip to content

Function

A function is a named group of commands that you can call repeatedly. A category contains definitions and creates corresponding call blocks according to them. Placing a definition on the workspace alone does not trigger its body.

Definition without result (procedures_defnoreturn)

What it does: Defines a function with a command name and body. Use, for example, to render the screen together or set the outputs. The parameters can be added via the gear wheel.

procedures_defnoreturn

Definition with result (procedures_defreturn)

What it does: Defines a function that returns a value from the result input after commands. It is suitable for repeated calculation. Parameters represent the values passed on each call.

procedures_defreturn

Call without result (procedures_callnoreturn)

What it does: Runs the defined function at a given point in the program and then continues with the next statement. It has inputs according to its parameters and has no value output.

procedures_callnoreturn

Call with result (procedures_callreturn)

What it does: Runs a function and provides its return value to the next block. The inputs correspond to the parameters of the definition. For example, you can save the result in a variable or use it in a condition.

procedures_callreturn

Conditional return (procedures_ifreturn)

What it does: Terminates the currently executing function prematurely if the condition is true. It also returns the attached value in the function with the result. It belongs inside a function, not in the main program loop.

procedures_ifreturn

Tips and pitfalls

  • The function does not run concurrently with the calling code. A long wait inside a function will also delay the main loop.
  • Shared project variables can be changed by the function; use parameters for values that you want to pass to each call separately.
  • Give all function paths with a result a meaningful return value. An early return terminates the remaining function statements.
  • An infinite loop inside a function does not allow it to return to the caller in the normal way.