Skip to main content

Variables - general information

note

This page has been automatically translated and has not been reviewed in detail yet. Therefore, the translation might not be completely accurate.

NeuroomNet supports the following data types

IconNameDescriptionExamples of values
Icon Boolean variableboolBoolean values (truth value) can only assume two states.true/false
Icon Number VariableNumberInteger values0 / 1 / 42
Icon Float VariableFloatFloating point number3.14 / 0.5
Icon Text VariableTextStringsHello / 0xff5a11
Icon Time VariableTimeFormatted time08:15 / 8:15am
Icon DateTime VariableDateTimeFormatted date and time02/15/2023/08:15

In addition, each data type is available as a list. The icon has three small dots on the left: Icon Bool Array Icon Number Array Icon Float Array Icon Text Array

As the name suggests, lists contain several Bool, Number, Float etc. values.

Basic ideas of data types

Text:     1 + 2 = 12

Number:    1 + 2 = 3

From this example it is easy to see that it makes a big difference whether processing software interprets corresponding input as a number or text.

Traditionally, most high-level languages use data types for variables. Some languages also forego the concept because it is sometimes more convenient. However, this usually has to be paid for with more effort in finding runtime errors.

In NeuroomNet we have also decided on data types, since NeuroomNet mainly communicates with devices from many manufacturers and these usually already define data types in their protocols. So if you receive a code in the form of "0123" from a device, you can rely on it being kept that way because you have defined - here comes a text. In an automatic conversion, this text would probably be interpreted as a number and converted to '123'.

Of course, in NeuroomNet you can also explicitly convert one data type to the other if you want.

Type conversion

You can convert one data type to another. In high-level languages, this process is also called typecasting. However, a conversion must be technically possible. The following examples are intended to illustrate which conversions work and which do not.

Note: Almost anything can be converted into text, which is why this direction is not specifically listed here.

Examples for converting a text variable ("Original Text") to Number, Float, Bool:

Original TextConvert to NumberConvert to FloatConvert to Bool
"Hello"ErrorErrortrue
"0"00.0false
"1"11.0true
"3.14"33.14true
"1234"12341234.0true
"12 34"ErrorErrortrue
""00.0false

Visibility of variables

The user mainly encounters the visibility of variables in the script blocks. Visible means from where can I access these variables. We differentiate between 'global' and 'block' variables. Variables created with the 'Global' attribute can be accessed from anywhere, for example from a dashboard or all scripts etc.

Variables with the 'Block' attribute can only be used by events or actions in the script block in which they were created.

Icon global variable Icon for global variables

Icon block variable Icon for block variables

Why global and block variables?

Actually, variables that can be accessed from anywhere would be sufficient for all use cases. So far, so true, but impractical. The number of global variables can then quickly skyrocket and become confusing.

It is often the case that you write the parameter of an event into a variable, only to test in the same block with an IF condition whether a certain value is in the variable. Since the names of global variables must be unique, you would have to come up with a new unique name for each block and the list of variables would quickly become very long. If a variable is only visible in the block, you can always use the same variable names for blocks that do similar things and you don't run the risk of using the variable somewhere else and triggering any side effects. Therefore, entire blocks including variables can also be copied. Usually you only have to adjust a few constants or component names.