Ankündigung

Einklappen
Keine Ankündigung bisher.

Define static variable?

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    Define static variable?

    Hello guys...
    How to do if I need to use some static variables? This could be a variable,defining last time I've did something.... The variable is only needed inside the actual logic, but I must not be reset....
    If I declare a new variable in Python called "last_time=5" will this be static and not resat?

    #2
    Hi Rasmus,

    usually I just define another sh.py-item and put the variable in there. By using caching, this can also make the variable "failsafe" (e.g. in case of power failure). Plus it enables you to communicate even between different logics.

    Some examples on how to use it (taken from a random place in one of my logics):

    Code:
     
     set:   sh.ventilation.power_state(1)
     read:  if sh.ventilation.power_state() == 0:
    Not sure if this is the way as it is intended to be used, but works for me.

    hth,
    /tom

    Kommentar


      #3
      Hello tom.Yes that was also my thoughts to do this... Which works perfectly... I was more wondering if there was a way, like when just typing a variable it creates a temporary variable - just with static

      Kommentar

      Lädt...
      X