Call Function
Invokes your custom-defined functions within a function stack, allowing for modular and reusable code.
Purpose
The Call Function enables you to:
- Execute custom functions you've defined elsewhere
- Reuse logic across multiple workflows
- Organize complex operations into manageable components
- Call methods attached to structs
- Execute functions asynchronously for parallel processing
Config
- From Struct: (Optional) Pointer to a struct instance when calling a method defined on a struct. Enables auto-suggestions for available methods.
- Function Name: The name of the function you want to call.
- Parameters: Input values required by the selected function. These must match the function's parameter types.
- Run Asynchronously: When enabled, executes the function in a separate thread and returns immediately with an
Async[T]
result. - Outputs: Variable names to store the function's return values.
Asynchronous Execution
When Run Asynchronously is enabled:
- The function executes in a separate thread and returns immediately
- Returns an
Async[T]
value whereT
is the return type of your function - Local scoping data is not directly available to the async function
- You should pass required data as parameters
- Avoid passing reference types used in the main stack to prevent race conditions
- You can expose specific variables to the async scope through the configuration panel
- For thread-safe data sharing, use
SyncList
orSyncMap
types
Return Value Handling
Depending on how the function is called:
Normal (Synchronous) Calls:
- Must assign variable names for each returned value
- Variable types must match the function's return types exactly
Asynchronous Calls:
- Returns immediately with an
Async[T]
object - For functions returning a single value:
Async[String]
,Async[Int]
, etc. - For functions returning multiple values: It automatically create a custom struct (e.g.,
Async[Data]
) and name of the struct can be configured usingTag
option - For functions with no return value: Returns
Async[Void]
For examples of working with asynchronous functions, see the Await Function
documentation that explains how to resolve data from asynchronous operations.
Use the Save & Update button to refresh parameter and return type references whenever the underlying function definition changes.
Example: Using a Custom Function
Define a Custom Function
Create a custom function named Capitalize
that takes one parameter (name
) and returns one output (also named name
).
Implement the Function Logic
Inside the function body, convert the input value to uppercase. Use the Return In Scope function to return the result and exit the function.
Call the Function
Use the Call Function to invoke your custom function with the required parameters. Assign the return value to a variable and use it in subsequent operations, such as printing the result.
Best Practices
- Function Modularity: Create single-purpose functions that do one thing well
- Consistent Naming: Use descriptive names for functions and their parameters
- Error Handling: Include appropriate error handling in functions that might fail
- Parameter Documentation: Add comments to describe parameter usage and requirements
- Asynchronous Considerations: Be careful about shared state in asynchronous functions
- Return Value Handling: Always handle all return values, including errors
- Function Updates: Use Save & Update when changing function signatures to keep calls in sync