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



Reply to topic  [ 21 posts ]  Go to page: Previous  1, 2
 My iPhone 4 control page 
Author Message

Joined: Mar 31, 2008
Posts: 738
Post Re: My iPhone 4 control page
Scotsman: This is a superb weather script. Thank you for your efforts.


I've written a few lines to parse out the text lines for the iphone. Just add the new "day1Period1Line1" etc variables and put this as a second action: embedded applescript in your time date action. Modify the control page to see the full forecast. If someone knows how to make it recognize words instead of splitting them that would be great. Modify the character numbers to fit your screen. I'm using Arial 14.

This has been updated to account for up to 6 lines of text.


Code: Select all
using terms from application "IndigoServer"
   tell application "IndigoServer"
      set day1Period1Forecast to value of variable "Wunderground_Day1Period1TextForecast" as string
      set day1Period2Forecast to value of variable "Wunderground_Day1Period2TextForecast" as string
      
      if length of day1Period1Forecast is less than 91 then
         set value of variable "day1Period1Line1" to (characters 1 through 45 of day1Period1Forecast) as string
         set value of variable "day1Period1Line2" to (characters 46 through -1 of day1Period1Forecast) as string
         set value of variable "day1Period1Line3" to ""
         set value of variable "day1Period1Line4" to ""
         set value of variable "day1Period1Line5" to ""
         set value of variable "day1Period1Line6" to ""
      end if
      
      if ((length of day1Period1Forecast is greater than 90) and (length of day1Period1Forecast is less than 136)) then
         set value of variable "day1Period1Line1" to (characters 1 through 45 of day1Period1Forecast) as string
         set value of variable "day1Period1Line2" to (characters 46 through 90 of day1Period1Forecast) as string
         set value of variable "day1Period1Line3" to (characters 91 through -1 of day1Period1Forecast) as string
         set value of variable "day1Period1Line4" to ""
         set value of variable "day1Period1Line5" to ""
         set value of variable "day1Period1Line6" to ""
      end if
      
      
      if ((length of day1Period1Forecast is greater than 135) and (length of day1Period1Forecast is less than 181)) then
         set value of variable "day1Period1Line1" to (characters 1 through 45 of day1Period1Forecast) as string
         set value of variable "day1Period1Line2" to (characters 46 through 90 of day1Period1Forecast) as string
         set value of variable "day1Period1Line3" to (characters 91 through 135 of day1Period1Forecast) as string
         set value of variable "day1Period1Line4" to (characters 136 through -1 of day1Period1Forecast) as string
         set value of variable "day1Period1Line5" to ""
         set value of variable "day1Period1Line6" to ""
      end if
      
      if ((length of day1Period1Forecast is greater than 180) and (length of day1Period1Forecast is less than 226)) then
         set value of variable "day1Period1Line1" to (characters 1 through 45 of day1Period1Forecast) as string
         set value of variable "day1Period1Line2" to (characters 46 through 90 of day1Period1Forecast) as string
         set value of variable "day1Period1Line3" to (characters 91 through 135 of day1Period1Forecast) as string
         set value of variable "day1Period1Line4" to (characters 136 through 180 of day1Period1Forecast) as string
         set value of variable "day1Period1Line5" to (characters 181 through -1 of day1Period1Forecast) as string
         set value of variable "day1Period1Line6" to ""
      end if
      
      if length of day1Period1Forecast is greater than 225 then
         set value of variable "day1Period1Line1" to (characters 1 through 45 of day1Period1Forecast) as string
         set value of variable "day1Period1Line2" to (characters 46 through 90 of day1Period1Forecast) as string
         set value of variable "day1Period1Line3" to (characters 91 through 135 of day1Period1Forecast) as string
         set value of variable "day1Period1Line4" to (characters 136 through 180 of day1Period1Forecast) as string
         set value of variable "day1Period1Line5" to (characters 181 through 225 of day1Period1Forecast) as string
         set value of variable "day1Period1Line6" to (characters 226 through -1 of day1Period1Forecast) as string
      end if
      
      
      --These are for period 2
      
      if length of day1Period2Forecast is less than 91 then
         set value of variable "day1Period2Line1" to (characters 1 through 45 of day1Period2Forecast) as string
         set value of variable "day1Period2Line2" to (characters 46 through -1 of day1Period2Forecast) as string
         set value of variable "day1Period2Line3" to ""
         set value of variable "day1Period2Line4" to ""
         set value of variable "day1Period2Line5" to ""
         set value of variable "day1Period2Line6" to ""
      end if
      
      if ((length of day1Period2Forecast is greater than 90) and (length of day1Period2Forecast is less than 136)) then
         set value of variable "day1Period2Line1" to (characters 1 through 45 of day1Period2Forecast) as string
         set value of variable "day1Period2Line2" to (characters 46 through 90 of day1Period2Forecast) as string
         set value of variable "day1Period2Line3" to (characters 91 through -1 of day1Period2Forecast) as string
         set value of variable "day1Period2Line4" to ""
         set value of variable "day1Period2Line5" to ""
         set value of variable "day1Period2Line6" to ""
      end if
      
      if ((length of day1Period2Forecast is greater than 135) and (length of day1Period2Forecast is less than 181)) then
         set value of variable "day1Period2Line1" to (characters 1 through 45 of day1Period2Forecast) as string
         set value of variable "day1Period2Line2" to (characters 46 through 90 of day1Period2Forecast) as string
         set value of variable "day1Period2Line3" to (characters 91 through 135 of day1Period2Forecast) as string
         set value of variable "day1Period2Line4" to (characters 136 through -1 of day1Period2Forecast) as string
         set value of variable "day1Period2Line5" to ""
         set value of variable "day1Period2Line6" to ""
      end if
      
      if ((length of day1Period2Forecast is greater than 180) and (length of day1Period2Forecast is less than 226)) then
         set value of variable "day1Period2Line1" to (characters 1 through 45 of day1Period2Forecast) as string
         set value of variable "day1Period2Line2" to (characters 46 through 90 of day1Period2Forecast) as string
         set value of variable "day1Period2Line3" to (characters 91 through 135 of day1Period2Forecast) as string
         set value of variable "day1Period2Line4" to (characters 136 through 180 of day1Period2Forecast) as string
         set value of variable "day1Period2Line5" to (characters 181 through -1 of day1Period2Forecast) as string
         set value of variable "day1Period2Line6" to ""
      end if
      
      
      if length of day1Period2Forecast is greater than 225 then
         set value of variable "day1Period2Line1" to (characters 1 through 45 of day1Period2Forecast) as string
         set value of variable "day1Period2Line2" to (characters 46 through 90 of day1Period2Forecast) as string
         set value of variable "day1Period2Line3" to (characters 91 through 135 of day1Period2Forecast) as string
         set value of variable "day1Period2Line4" to (characters 136 through 180 of day1Period2Forecast) as string
         set value of variable "day1Period2Line5" to (characters 181 through 255 of day1Period2Forecast) as string
         set value of variable "day1Period2Line6" to (characters 226 through -1 of day1Period2Forecast) as string
      end if
      
   end tell
end using terms from






[edit Feb 27, 2011] Corrected a couple of numbers in the less than/greater than statements.


Attachments:
Weather Text.tiff
Weather Text.tiff [ 43.64 KiB | Viewed 3054 times ]


Last edited by hamw on Tue Mar 01, 2011 6:26 am, edited 4 times in total.

Tue Feb 22, 2011 9:33 pm
Profile

Joined: Mar 31, 2008
Posts: 738
Post Re: My iPhone 4 control page
Realized that forecasts came in different lengths. Modded the script above to account for up to 5 lines of text.

Again, just change the character numbers to match your text size/screen width.

Edited script Feb 27 as the numbers in the less than/greater than statements were off by a digit.


Sun Feb 27, 2011 8:55 am
Profile

Joined: Aug 14, 2010
Posts: 51
Location: Austin, Texas
Post Re: My iPhone 4 control page
That's awesome hamw. I was wondering how on earth I could get my forecast variables to split across lines. I look forward to adding that to my page, but also hoping that v.5 is going to fix this problem without Applescript gymnastics.

You asked about my weather icons. I uploaded them to the user contribution library here:

http://www.perceptiveautomation.com/filelib/index.php?id=130

Hope that helps.


Sun Feb 27, 2011 8:20 pm
Profile

Joined: Mar 31, 2008
Posts: 738
Post Re: My iPhone 4 control page
Thanks, but it was your script that got me motivated. However, I just got a six line forecast so will have to mod script again..... :roll:

BTW got the icons, they are great.


Sun Feb 27, 2011 9:30 pm
Profile

Joined: Mar 31, 2008
Posts: 738
Post Re: My iPhone 4 control page
Ok, script is updated for 6 lines of text. Let me know if there are any issues.

BTW I have not looked too closely at the weather script but a lot of times when the day prediction (not the forecast but the little blurb for the six day forecast) says clear, the weather condition lists partly cloudy and that is the icon that is selected. Any ideas? Also, is there a way to set the time zone? The icons remain in night phase well after dawn. For instance the night icon is currently displayed and it is 7:30 AM. May just be Wunderground....


Tue Mar 01, 2011 6:31 am
Profile

Joined: Jul 22, 2011
Posts: 11
Post Re: My iPhone 4 control page
Sounds like great pages, but for some reason I cant get them to show here in the forum? anybody else not seeing them?
are they deleted maybe?


Fri Jul 22, 2011 7:24 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 21 posts ]  Go to page: Previous  1, 2

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.