Functions
Function blocks allow defining custom procedures within your design. These functions will be translated into code just as expected.
Functions can return up to one value and can receive a fixed number of arguments. To customize the arguments to the function, click the gear icon on the function block. The arguments can then be accessed with the Variables toolbox on the left.
Give your functions a meaningful name and description to easily recall their purpose later in the design process. A description can be provided using the question mark button on the block.
Function block without return value:
Function block with return value:
Example
The function definition above will result in the following code:
# Returns the sum of two even numbers
def add_even(x, y):
if x % 2 == 1:
x = x + 1
if y % 2 == 1:
y = y + 1
return x + yComplex functions are hard to implement using visual programming and should be implemented directly in code. For this, just leave the function empty in the design and implement its functionality later on in the exported code.
Advanced usage
Take a look at the Transformations guide for some more advanced uses of functions.