logo elektroda
logo elektroda
X
logo elektroda

OpenBeken platform conditional instruction If and many actions after it.

Honsu 531 1
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 20998111
    Honsu
    Level 3  
    How to properly write if else statements with multiple actions.
    addEventHandler OnClick 14 backlog   if $CH11>0 then POWER1 OFF; setChannel 11 0  else  POWER1 ON; setChannel 11 15 

    if I write it this way the code executes.
    alias warunekIF  backlog   POWER1 OFF; setChannel 11 0
    alias warunekELSE backlog   POWER1 ON; setChannel 11 15
    addEventHandler OnClick 14 backlog   if $CH11>0 then warunekIF  else warunekELSE 

    why do I sometimes see instructions in the if condition in quotes?

    Where can I play the openBeken simulator in the Windows executable version.
    Does it have some kind of syntax editor etc known from programming environments.
  • ADVERTISEMENT
  • #2 21042161
    p.kaczmarek2
    Moderator Smart Home
    Apologies for the slow response.

    The support of string execution in inverted commas is somewhat a remnant of the slightly simpler parser, but both notations are supported.

    The best way is to abbreviate commands using aliases, but the parser is being developed all the time, along with unit tests so that functionality is not lost, e.g.:
    https://github.com/openshwprojects/OpenBK7231...blob/main/src/selftest/selftest_expressions.c

    The simulator has recently been published in a test version, feel free to try it out, if you have any questions I will help:
    OpenBeken IoT device simulator - first early alpha version for testing .
    Helpful post? Buy me a coffee.
ADVERTISEMENT