Jump to content

Variables ?


hagak

Recommended Posts

Posted

So I notice isy has varaibles for use with Programs however the Wiki does not seem to mention them and in fact mentions using Programs to accomplish the same task which seems bulky to me.

I assume this is because variables are a newer feature than the Wiki entries.

 

Question I have is I was playing around with variables to create a Countdown type feature. ie press a button it decrements a variable with each press. This appeared to work fine. However the problem I had was I had 2 other programs whose if statement ran if the variable == 0 for one and the other was variable > 0.

 

Issue was those programs never ran. I would think those programs if statement would get evaluated anytime the variables value changed.

 

Any ideas why that would not work?

 

Count == 0

If
       $TestCountDown is 0

Then
       Set 'Office / Office-Chair-Lamp' Off

Else
  - No Actions - (To add one, press 'Action')

 

CountDown >0

If
       $TestCountDown > 0

Then
       Wait  10 seconds
       $TestCountDown -= 1

Else
  - No Actions - (To add one, press 'Action')

 

Set countdown

If
       Status  'Office / Office-Motion-Sensor' is On

Then
       $TestCountDown  = 4

Else
  - No Actions - (To add one, press 'Action')

 

I used a motion sensor to reset the count down. This program runs as expected, however the 2 that trigger on the $TestCountDown value do not run. If I manually run (if) on each they run as expected.

Posted

There is a forum Category dedicated to Variables. The first few topics cover Variables in detail.

 

If a Program is not being triggered with a Variable the variable is an Integer rather than a State variable. Both types are identical except State variables trigger Programs, Integer variables do not. This is all covered in the initial topics under the Variables forum category.

Posted

What Lee said plus a suggeston:

 

When you name your variables, start all integer variables with an "i" and all state with an "s". This makes it easy while writing and trouble shooting your programs to know what you are dealing with.

 

i.e.

"iCountdown"

"sCoundown"

Guest
This topic is now closed to further replies.

  • Recently Browsing

    • No registered users viewing this page.
  • Who's Online (See full list)

    • There are no registered users currently online
  • Forum Statistics

    • Total Topics
      37k
    • Total Posts
      371.4k
×
×
  • Create New...