This has been broken so long that I don't even remember what it's supposed to look like, but I know it's closer than it was before I started messing with it. I have modified the script so that it just reads the forecast without the other 'garbage', which looks fine when you click on it and it opens in a message box, but in the GUI the ForTx's are split like ''Tonight:'' in the first one, then the actual forecast for tonight in the next, then a line feed in the next, then ''Tomorrow:'' in the next, then the actual forecast for tomorrow in the next, and so on.
I could really use a hand because this type of code (RegEx, etcetera) is SOOOO not my strongest skill.
The only changes I've made have been in the Refresh() function (and maybe that's the problem). Further, I've made so many changes (and un-changes) that I've almost lost track of what I've twiddled with.
Anyway, I'll keep trying, but I'm about spent for tonight and thought I'd post what I've done so far (only posted the function)... Maybe someone will have some suggestions.
Code:
Refresh() {
SetBatchLines, -1
global temp, forecast, batchlines
GuiControl, Disable, ForUD
Set("Title", "Loading Weather...")
Set("Sub", "...")
Set("ForT", "Loading Weather...")
Set("ForTx", "...")
Menu, Tray, Tip, Loading Weather...
SB_SetText("Loading...")
url := Get("SetLoc")
StringMid, url, url, InStr(url, "(") + 1, InStr(url, ")") - InStr(url, "(") - 1
url := "http://xml.weather.yahoo.com/forecastrss?prevcache=" . A_Now . "&p=" . url
If Get("SetTempC")
url = %url%&u=c
Else url = %url%&u=f
file = ~wthr%A_Now%.tmp
URLDownloadToFile, %url%, %file%
If XMLRead(file, "rss", "attribute('xmlns:yweather')") != "http://xml.weather.yahoo.com/ns/rss/1.0" {
MsgBox, 16, Error, The specified Yahoo! country code seems to be invalid or there has been an error with downloading.
Return
}
Set("Title", XMLRead(file, "rss.channel.yweather:location", "attribute('city')") . " Weather")
t1 := XMLRead(file, "rss.channel.yweather:wind", "attribute('chill')")
. "°" . XMLRead(file, "rss.channel.yweather:units", "attribute('temperature')")
. " - " . XMLRead(file, "rss.channel.item.yweather:condition", "attribute('text')")
Set("Sub", t1 . " (High: " . XMLRead(file, "rss.channel.item.yweather:forecast", "attribute('high')")
. "°" . XMLRead(file, "rss.channel.yweather:units", "attribute('temperature')")
. " / Low: " XMLRead(file, "rss.channel.item.yweather:forecast", "attribute('low')")
. "°" . XMLRead(file, "rss.channel.yweather:units", "attribute('temperature')") . ")")
t := XMLRead(file, "rss.channel.item.title")
StringReplace, t, t, Conditions for%A_Space%
Set("ForT", t)
Menu, Tray, Tip, % Get("ForT") . "`n" . t1
t := XMLRead(file, "rss.channel.item.link")
StringTrimLeft, t, t, InStr(t, "*")
Icon(XMLRead(file, "rss.channel.item.yweather:condition", "attribute('code')"))
URLDownloadToFile, %t%?preventcache=%A_Now%, %file%
FileRead, s, %file%
StringTrimLeft, forecast, s, InStr(s, "<h3>Detailed Local Forecast</h3>")
;StringTrimLeft, forecast, forecast, InStr(forecast, "<h3>Detailed Local Forecast</h3>")
StringMid, forecast, forecast, InStr(forecast, "<li><strong>")
, InStr(forecast, "</ul>") - InStr(forecast, "<li><strong>") - 1
forecast := plaintxt(forecast)
StringReplace, forecast, forecast, `r
StringReplace, forecast, forecast, `n, `n, All UseErrorLevel ;Counts linefeeds, but not sure how that helps
StringLeft, t, forecast, InStr(forecast, "`n") ;two `n ("`n`n") works for first ForTx, but then breaks
GuiControl, % "+Range1-" . ErrorLevel + 1, ForUD
GuiControlGet, tp, Pos, ForUD
GuiControl, Move, ForUD, w%tpw%
Set("ForTx", t)
FileDelete, %file%
FormatTime, t, , h:mm tt
SB_SetText("Last Updated: " . t)
GuiControl, Enable, ForUD
SetBatchLines, %batchlines%
}