|
|
|
Page 1 of 1
|
[ 4 posts ] |
|
Creating variables for sunrise and sunset
| Author |
Message |
|
PaulV
Joined: Aug 12, 2009 Posts: 16
|
 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 |
|
 |
|
berkinet
Joined: Nov 18, 2008 Posts: 1721 Location: Berkeley, CA
|
For AppleScript's purposes, the application name is IndigoServer. So, try...
tell application "IndigoServer"
...
|
| Tue Sep 29, 2009 11:59 am |
|
 |
|
jay (support)
Site Admin
Joined: Mar 19, 2008 Posts: 6665 Location: Austin, Texas
|
 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)
|
| Tue Sep 29, 2009 12:13 pm |
|
 |
|
PaulV
Joined: Aug 12, 2009 Posts: 16
|
 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 |
|
|
|
Page 1 of 1
|
[ 4 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 1 guest |
|
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
|
|