Functions
Defining a Function
Here is a C# function compared to the Linx version:
- The Function definition lives in the Solution Explorer.
- Its Parameters property defines the input parameters.
- Its Result property defines the output results.
- The central working area contains the body of the function.
- Linx does not have an explicit ‘return’. When the Function finishes the Result set is returned.
Setting the result of a Function
- Use the Return function, which comes from the Linx Plugin.
- The Value property of the Return function must be set to what the function's result value should be. Select a relevant in-scope item from the dropdown list, or enter a literal value in the property field, or use the Expression Editor in the dropdown to build the expression. The ‘=’ in front of the value indicates that the value is an expression and not a literal value.
Click DEBUG to run the Function and see the result.
Calling a Function
Calling a Function is the same as one function calling another in programming.
- Functions are dragged onto the body of another Function to call them.
- Parameters of the called Function are visible as Properties.
Click DEBUG to run the Function and see the result.
Using the result of a Function
The body of a Function works exactly like the body of a programming function. Statements and expressions are added in a top down fashion and can refer to items in its scope. When we add another AddNumbers Function to the body of UseAddNumbers we can set its parameters to the result of the first AddNumbers:
To set the value of any of the sub-functions' results or calculations to the main function's result, add a Return function at the end of the execution sequence:
Click DEBUG to run the Function and see the result.