Additional Information
It is useful to define two types of variables here: Input Variables, and Implicit Variables.
Input VariablesWhen an input is created on the formula node by right-clicking and selecting
Add Input, the wire type that is wired to that input node defines the type of that variable. In the figure below you can see that the variables in the Formula Node are type defined based on the data type wired to each respective input.
Implicit Variables
An Implicit Variable is a variable that is created in the formula node as a consequence of the code. When a variable is created in the Formula Node as the result of some operation from two previously defined variables, it is not automatically defined. Refer to the figures below.
The block diagram shows a broken arrow, even though the text code might look OK. The Error list above shows that the variable Z is undefined. This can be fixed either by declaring an output variable or by programmatically defining the variable.
Output VariableBy making an implicit variable an output of the Formula Node, it will be defined as a Double Precision type, regardless of the type of the variables used to create the new variable (e.g. X and Y are Long (signed 32-bit), but Z is a Double. See below).
ProgrammaticallyYou can programmatically define variables by using the following commands and syntax.
Data Type | DBL | SGL | I8 | I16 | I32 | U8 | U16 | U32 |
---|
Command | float, float 64 | float32 | int8 | int16 | int, int32 | uInt8 | uInt16 | uInt32 |
---|
Syntax | float x, float64 x | float32 x | int8 x | int16 x | int x, int32 x | uInt8 x | uInt16 x | uInt32 x |
---|
The following figure shows this implemented. This is useful to set the output type of a variable to something other than Double. It also makes it unnecessary to wire each variable in the text code to an output to be defined.