|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Fri Apr 27, 2012 5:06 pm
Dummy Gauge |
I have a button that changes color based on weather or not enough time has passed for me to repeat the associated command.
Code: |
#CALL %btncol(Jerky,,firebrick)
#ALARM "keepJerking" +31:00 {#CALL %btncol(Jerky,,lime)} |
I was trying to stick a reference to the time into the button caption, but it doesn't want to play along.
Code: |
#VAR jerky {%eval(%alarm(keepjerking)/1000.0)}
#FUNC jerky {
$sec=%eval(%alarm(keepjerking)/1000.0)
#IF ($sec>0) {#RETURN $sec}
} |
Both of those were input via the GUI to prevent premature evaluation.
However, as a variable, it doesn't recognize when its value changes.
And as a function, it just displays the literal zscript instead of evaluating. |
|
_________________ Discord: Shalimarwildcat |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Fri Apr 27, 2012 5:39 pm |
I tried doing this on a regular gauge, but %btncol only seems to change the current value color.
Also it only has 2 color arguments, where as gauges have 3 color arguments. |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Fri Apr 27, 2012 7:05 pm |
The value of the variable _won't_ change unless you keep using the #VAR command to reset it. A variable is constant until it is explicitly changed. Above, you are setting the variable to a string "%eval(%alarm(keepjerking)/1000.0)", which is constant. Unless you keep explicitly changing the value of @jerky, it will not change.
The way to do it is to have an alarm or loop constantly changing the value of @jerky every so often. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Fri Apr 27, 2012 9:19 pm |
Should not the function option have gotten around that?
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Sat Apr 28, 2012 2:14 pm |
I'm not sure about the function. As I recall, captions don't check the value unless it thinks something has changed. For variables, this is triggered when the variable is internally marked as "updated". I'm not sure what causes the caption to check the value of a function.
|
|
|
|
|
|