View unanswered posts | View active topics It is currently Wed May 22, 2013 4:06 pm



Reply to topic  [ 9 posts ] 
 Variable Number Change Issue 
Author Message
Online

Joined: Nov 26, 2009
Posts: 925
Location: Kalispell, MT
Post Variable Number Change Issue
Hey,

For a long time I've run an AS to reduce the temp variable reported by NOAA to an integer,
e.g. 35.0 to 35, triggered by any change to it's variable.

Odd thing is now when it becomes for example 28.0 from any temp other than 28 it will work.
If it is 28 and it becomes 28.0 it apparently isn't seen as a change and the AS to reduce
it to an integer doesn't run.

Has something changed in v5 that would make it behave differently?

Thanks,

Carl


Thu Feb 16, 2012 12:52 am
Profile
Site Admin
User avatar

Joined: Jan 27, 2003
Posts: 11692
Location: Texas
Post Re: Variable Number Change Issue
Yes, we added some changes recently so that if the values are numbers then they are compared as numbers in all cases (and not strings). So the trigger won't fire since 28 is numerically equivalent to 28.0.

A workaround for your case that I believe would work would be to create a new Indigo variable for the integral value. Then modify your trigger to read from the main value and put the truncated version into the new integral variable.

_________________
Image


Thu Feb 16, 2012 7:58 am
Profile WWW
Online

Joined: Nov 26, 2009
Posts: 925
Location: Kalispell, MT
Post Re: Variable Number Change Issue
Thanks Matt. What I ended up doing was triggering off
any change in the last update variable...works fine.

Carl


Thu Feb 16, 2012 9:17 am
Profile
Online

Joined: Nov 26, 2009
Posts: 925
Location: Kalispell, MT
Post Re: Variable Number Change Issue
Well, I thought it was working fine. Occasionally the temp will update without
any change to the Weather_Update_Time variable, which is what I've been triggering
the integer fix from.

Any chance that an option could be included sometime to look for ANY change to a variable?

Not sure I'm understanding you suggestion above about using a second variable.
If Indigo can't recognize the difference between a 10.0 or a 10 what should I be
triggering from?

Thanks,

Carl


Thu Feb 23, 2012 1:07 pm
Profile
Site Admin
User avatar

Joined: Jan 27, 2003
Posts: 11692
Location: Texas
Post Re: Variable Number Change Issue
ckeyes888 wrote:Not sure I'm understanding you suggestion above about using a second variable.

The point is to have 2 variables:

Weather_Temperature_F, which contains the raw real (floating point) precise number.

Weather_Temperature_F_int, which contains the integer version.

It sounds like you want the integer version for whatever reason, so everywhere that you are currently referencing (control pages?) Weather_Temperature_F you would instead reference Weather_Temperature_F_int.

Then all you have to do is create a trigger for whenever Weather_Temperature_F changes have it stuff the integer version of the variable into Weather_Temperature_F_int.

ckeyes888 wrote:If Indigo can't recognize the difference between a 10.0 or a 10 what should I be
triggering from?


In that case it doesn't matter if it doesn't trigger. Weather_Temperature_F_int will still have the correct integer value in it for the last time it did trigger (when there was a real change).

_________________
Image


Thu Feb 23, 2012 1:33 pm
Profile WWW
Online

Joined: Nov 26, 2009
Posts: 925
Location: Kalispell, MT
Post Re: Variable Number Change Issue
Yet another Doh! moment.

Thanks,

Carl


Thu Feb 23, 2012 2:07 pm
Profile

Joined: Jun 02, 2008
Posts: 75
Location: Ireland
Post Re: Variable Number Change Issue
Guys, would you be able to advise how or what to set the Weather_Temperature_F_int variable

Then all you have to do is create a trigger for whenever Weather_Temperature_F changes have it stuff the integer version of the variable into Weather_Temperature_F_int.


Tue Mar 27, 2012 11:18 am
Profile
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6659
Location: Austin, Texas
Post Re: Variable Number Change Issue
In Python:

Code: Select all
intValue = int(float(indigo.variables[FLOAT_VAR_ID].value)) # ID of "Weather_Temperature_F"
indigo.variable.updateValue(INT_VAR_ID, intValue)           # ID of "Weather_Temperature_F_int"


In AppleScript:

Code: Select all
set intValue to value of variable "Weather_Temperature_F" as integer
set value of variable "Weather_Temperature_F_int" to intValue

_________________
Jay (Indigo Support)
Image


Tue Mar 27, 2012 11:49 am
Profile WWW

Joined: Jun 02, 2008
Posts: 75
Location: Ireland
Post Re: Variable Number Change Issue
Brilliant, thanks for that Jay...


Tue Mar 27, 2012 12:06 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 9 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.   Template designed by STSoftware.