View unanswered posts | View active topics It is currently Wed Jun 19, 2013 2:43 pm



Reply to topic  [ 4 posts ] 
 Creating variables for sunrise and sunset 
Author Message

Joined: Aug 12, 2009
Posts: 16
Post Creating variables for sunrise and sunset
I'd like to create variables that contain the values for sunrise and sunset so that I can have them available for quick reference from within Indigo Touch. I tried creating an Applescript that would run once a day, but I don't have much experience with Applescript and didn't get very far. If anyone can suggest a better approach, I'm open to it. In the meantime, here's my attempt at Applescript.

tell application "Indigo 4"
set theSunrise to calculate sunrise for (current date)
set theSunset to calculate sunset for (current date)
end tell


When I try to compile, AppleScript Editor returns "Expected end of line but found identifier" and highlights "sunrise" in the second line. Any suggestions?


Thanks in advance,
Paul

_________________
Indigo Server: Mac mini 2.26 GHz Core 2 Duo/4GB RAM/500 GB HD


Tue Sep 29, 2009 11:26 am
Profile
User avatar

Joined: Nov 18, 2008
Posts: 1743
Location: Berkeley, CA
Post 
For AppleScript's purposes, the application name is IndigoServer. So, try...
tell application "IndigoServer"
...


Tue Sep 29, 2009 11:59 am
Profile
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6856
Location: Austin, Texas
Post Re: Creating variables for sunrise and sunset
PaulV wrote:I'd like to create variables that contain the values for sunrise and sunset so that I can have them available for quick reference from within Indigo Touch. I tried creating an Applescript that would run once a day, but I don't have much experience with Applescript and didn't get very far. If anyone can suggest a better approach, I'm open to it. In the meantime, here's my attempt at Applescript.

tell application "Indigo 4"
set theSunrise to calculate sunrise for (current date)
set theSunset to calculate sunset for (current date)
end tell


When I try to compile, AppleScript Editor returns "Expected end of line but found identifier" and highlights "sunrise" in the second line. Any suggestions?


Thanks in advance,
Paul


2 issues:

1) The tell should go to "IndigoServer", not "Indigo 4" - Indigo 4 is the client application.
2) Your script will set AppleScript variables to the relevant times, but it won't set Indigo variables. Assuming that you've already created "theSunrise" and "theSunset" in Indigo's variable window, this is probably what you need:

Code: Select all
tell application "IndigoServer"
   set value of variable "theSunrise" to ((calculate sunrise) as string)
   set value of variable "theSunset" to ((calculate sunset) as string)
end tell

_________________
Jay (Indigo Support)
Image


Tue Sep 29, 2009 12:13 pm
Profile WWW

Joined: Aug 12, 2009
Posts: 16
Post Re: Creating variables for sunrise and sunset
Thanks berkinet and jay for your input.

Jay, your script did the trick. However, the value is too long to display in Indigo Touch.

Value: Wednesday, September 30, 2009 6:57:27 AM
Display Value: Wednesday, September 30, 2009 6:57:2...

The displayed value in this case is still OK, but it's only a few characters away from no longer being useful, so I altered your script to the following

tell application "IndigoServer"
    set value of variable "theSunrise" to ((time string of (calculate sunrise)) as string)
    set value of variable "theSunset" to ((time string of (calculate sunset)) as string)
end tell


so now it displays just the time, which is just what I'm looking for. Thanks again for your help.


Paul

_________________
Indigo Server: Mac mini 2.26 GHz Core 2 Duo/4GB RAM/500 GB HD


Tue Sep 29, 2009 12:45 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 0 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.