Float Expression | Provides the possibility to write logical C# expressions with a Float as resulting output value. | |
Int Expression | Provides the possibility to write logical C# expressions with an Int as resulting output value. | |
String Expression | Provides the possibility to write logical C# expressions with a String as resulting output value. | |
Boolean Expression | Provides the possibility to write logical C# expressions with a Boolean as resulting output value. Additional it provides True and False Event outputs. |
Expressions Nodes can combine multiple input properties, perform numeric/string operations on the inputs and provide the result as an output property. They can be thought of as mini C# sharp functions and follow the C# syntax. The number and types of inputs can be adjusted by using the Custom Model.You can either use a single statement or create a Codeblock with a return-statement.
The Expression Nodes have been designed for simple operations and input types only. To avoid their limitations or to use more complex variable types as inputs, use the Script Node instead.
A single statement expression is a simple one-line calculation that has one result, for example calculating the sum of two inputs. Using a single statement is fairly easy and you only have to input something returnable that resolves to the type of the expression.
A String Expression with four input properties and the single statement expression EXPRESSION is internally roughly translated to something like the following:
String expressionMethod(String A, String B, String C, String D) { return EXPRESSION; }
When using a one line statement you may not use control flow like an if-statement. Instead you can use an in-line if:
boolean_expression ? true_value : false_value
Loops are not possible at all with a single statement, neither are you able to assign local variables. If you want to do so, use a Multiple Statement Expression.
If you want to be able to use control flow or use local variables you can define a Codeblock with multiple statements. You need to place curly braces in front of and at the end of your code and make sure that every execution branch has a return statement. A simple Expression could look something like this:
{ STATEMENTS return RESULT; }
The STATEMENTS can consist of as many variable declarations or if-,while or for-statements as you need to. Be sure to stick to the C# syntax.
A + B | Sum of A and B for numeric expressions or the concatenation for string expressions. |
(A + 1.0) * B | Product of B and the sum of A and 1. |
Math.Sin(A / 180.0 * Math.PI) | Sine of the input degrees given in angle. |
Math.Asin(A) * 180.0 / Math.PI) | Inverse sine of the given value A, converted to degrees. |
(A == 6) ? 1:0 | Return 1 if A is equal to 1.6, otherwise return 0. |
(A != B) ? 1:0 | Return 1 if A is not equal to B, otherwise return 0. |
(A < 0) ? 0 : A | Return 0 if A is smaller than 0, otherwise return A. |
(A >= 0) ? 0 : A | Return 0 if A is greater than or equal to 0, otherwise return A. |
(A < 10) ? 10: ( (A > 20) ? 20 : A) | Returns A clamped into the the interval 10 to 20. |
(double)(int)A | Converts A into an integral value (all fractions are removed) and converts it back to double. |
Convert.ToString( Convert.ToInt32(A) * Convert.ToInt32(B)) | Convert the two input strings to integers, multiply them and convert the result back to a string |
{ int b = 0; for(int i = 1; i <= A; i++) b = b + i; return b; } |
|
{ int b = 1; if(A<=1) return 1; for(int i = 1; i < A + 1; i++) b = b * i; return b; } |
|
{ int result = 0; for(int i = 0; i < A.Length; i++) { result += A[i]; } return result; } |
|
{ var dt = System.DateTime.UtcNow.AddHours(TZ); var s1 = dt.ToString("MMMM d, yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); var s2 = dt.ToString(" tt", System.Globalization.CultureInfo.InvariantCulture).ToLower(); return s1 + s2; } |
|
When creating an Expression you can consider the following using directives as given.
using System; using System.Linq; using System.Xml.Linq;
Since the System namespace has been made available, all functions in the Math Namespace, theConvert Class and all String operations are supported.