Seite 1 von 1

#1 Unterschiedliche Variablen ?

Verfasst: Do 4. Sep 2014, 13:10
von koboldo
Moin....
was ist der Unterschied von den folgenden Codezeilen, wenn ich diese nicht in einer Funktion eingebe, sondern z.B. ganz oben als erstes im Lua Code ?

1. roll_rel_19_1_flag = use 'LCN.relay.0.19.1'

2. down = {'11------';'--11----';'----11--';'------11'}

3. set ('VAR.KOBELKA.event.lichtaussen',"0")

Es werden doch bei allen drei Zeilen Variablen erstellt die ich irgendwo im weitern Lua-Code weiterverarbeiten kann, z.B. auch in anderen Funktionen....
Wo ist hier nun der genaue Unterschied ? (es geht hier jetzt nicht darum das die oben genannten Variablen einen anderen Inhalt haben ;-) )


Gruß
Jörg

#2 RE: Unterschiedliche Variablen ?

Verfasst: Do 4. Sep 2014, 13:15
von DOMIQ-Support
In the first line you declare a variable that will refer to an object. In the second line you declare a table (which is an ordinary object in lua). And in the third line you invoke the set function that will set value of a given identifier.

#3 RE: Unterschiedliche Variablen ?

Verfasst: Do 4. Sep 2014, 13:19
von koboldo
Und 1. und 2. tauchen nicht unter Zustand auf, aber können genauso im Code genutzt werden und brauchen nicht mit get in Funktion geholt werden...oder ?

#4 RE: Unterschiedliche Variablen ?

Verfasst: Do 4. Sep 2014, 13:30
von DOMIQ-Support
The first 2 won't be visible in the State tab, but you can refer to those variables in the Logic tab. You can get value of the variable declared in the first line by typing something like this: newValue = variable.value, for example relValue = roll_rel_19_1_flag.value. You can use it inside function or so.
The second variable is just a lua table and should be handled as a lua table:) So for example down[1] will get first element and so on (remember that tables indexes in lua starts at 1 not at 0 like in the most programming languages):)

#5 RE: Unterschiedliche Variablen ?

Verfasst: Do 4. Sep 2014, 13:40
von Beleuchtfix
One more:
set and get take a while! If you use within the lua code set and try to use it later down in the code again, most likely the variable is not updated yet.

Gruß
Florian

#6 RE: Unterschiedliche Variablen ?

Verfasst: Do 4. Sep 2014, 13:42
von koboldo
Thanks Piotr :thumbup:

#7 RE: Unterschiedliche Variablen ?

Verfasst: Do 4. Sep 2014, 14:55
von DOMIQ
Hi, set and get are synchronous calls, if you do set then following get will retrieve changed value.
On the other hand command sends a message to STATE, which means that new value will be only visible in next script execution.
Most of the objects created by use perform any set operations through the command API.