Variables andKNX™ group addresses
P.
158 of 349
Variables
Some examples
Not permissible here...
... but here
No special characters in
variable names
Conversion
Implicit conversion
Variables
start with letters, followed by any number and combination of letters or numbers, and the
“_“ character. Variables are initialized with a value or function. Opposed to keywords and function
names, upper and lower case is respected.
Therefore, for example
address
and
Address
are different variables.
During the allocation of a variable and its processing, the compiler “EibParser“ always
checks the data type and prevents improper combinations of incompatible data types by an
error message when generating the user program. Therefore, no accidental overflow,
numerical problems, etc. may occur.
If you want to combine variables with different data types, use the
convert
-function (see page ).
Each variable must be initialized only once. The declaration of variables must therefore be unique.
a=123
A1=1b01
address=A1 or 0b01
Address=4%+5%+23u08
Value=4e4*0.2
w=4e16f32
Variables may not be defined depending on themselves (“recursion“). Therefore, the following
expression is invalid as a definition:
a=a+1
In contrast, it is permissible to program a counter using variables in this way:
//Declaration
a=0
//Counting
if (sun()) then a=a+1 endif
Umlauts are not allowed in variable names. Therefore, the following expression
is invalid
KücheLightOn=1b01
Only variables with a valid data type may be associated. Some functions require different or the
same data types as arguments. To link any data types to each other, the
convert
-function (see page
Fehler: Referenz nicht gefunden) has to be used.
For example: An 8 bit unsigned value is to be added with a signed 16 bit value:
Var1=10u08
Var2=300s16
// Var3=310
Var3=convert(Var1,Var2)+Var2
Both
Var2
, as well as
convert
(
Var1
,
Var2
)
are defined with data type s16. This is recognized by the
built-in compiler of the Enertex
®
EibStudio, and therefore it defines the data type of Var3 on its own.
This is called
implicit conversion
, since the user does not explicitly set the type of Var3. In any
case, the compiler checks the data types of variables and their linkages.
HandbuchEibPC_USA-30.odt, 2017-05-11
Enertex
®
Bayern GmbH - Erlachstraße 13 - 91301 Forchheim - [email protected]