Jump to content

Bit of help?


Recommended Posts

I realize the code is probably terrible and not the right way to do it. Which is why i am here. I would like some one to look at this. Everything works fine (at least here on my computer) The problem i have run into is this:

When the message box appears at the end, i would like it check if line 26 ($ForecastToday) is either Sunny, Storm, Snow. When i to add them with the current "IF Then" that choose which message box appears, it was often wrong. Basically i would like a Temp vs Forecast. I know there are other weather scripts, but I am so new to this i just can't grasp it.

I tried something along this but failed:

If $ForecastToday > $LowTemp Or $ForecastToday < $HighTemp And Not $ForecastToday = 'Storm' And Not $ForecastToday = 'Snow' Then
    MsgBox(0, 'Great Weather!', 'Go Riding!' & @CRLF & 'Your Max Temp' & @CRLF & $HighTemp & @CRLF & 'You Min Temp' & @CRLF & $LowTemp & @CRLF & @CRLF & $ForecastToday & @CRLF & $ForecastTomorrow)
ElseIf $ForecastToday <= $LowTemp Or $ForecastToday >= $HighTemp Or $ForecastToday = 'Storm' Or $ForecastToday = 'Snow'  Then
    MsgBox(0, 'Bad Weather', 'Fuck That!' & @CRLF & 'Your Max Temp' & @CRLF & $HighTemp & @CRLF & 'You Min Temp' & @CRLF & $LowTemp & @CRLF & @CRLF & $ForecastToday & @CRLF & $ForecastTomorrow)
EndIf

Whole Code:

If FileExists('C:\\Program Files\\MotoWeather\\Config.ini') Then
Else
    DirCreate('C:\\Program Files\\MotoWeather')
    $LowTemp = InputBox('Should You Ride Today?', 'Enter the LOWEST temperature (Fahrenheit) you would ride in')
    $HighTemp = InputBox('Should You Ride Today?', 'Enter the HIGHEST temperature (Fahrenheit) you would ride in')
    $Zip = InputBox('AutoIt', 'Enter your zip code')
    IniWrite('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'Low', $LowTemp)
    IniWrite('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'High', $HighTemp)
    IniWrite('C:\\Program Files\\MotoWeather\\Config.ini', 'Zip', 'Code', $Zip)
EndIf
$Zip = IniRead('C:\\Program Files\\MotoWeather\\Config.ini', 'Zip', 'Code', "")
$LowTemp = IniRead('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'Low', "")
$HighTemp = IniRead('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'High', "")
Opt("WinWaitDelay", 250)       ;250 milliseconds
Sleep(1000)
Run('C:\\Program Files\\Internet Explorer\\iexplore.exe', '', @SW_HIDE)
Opt("WinTitleMatchMode", 2);1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
WinWaitActive('Internet Explorer')
WinActivate('Internet Explorer')
$status = StatusbarGetText("Internet Explorer")
If $status = 'Done' Then
EndIf
Send('!d')
Send('^a')
Send('{DELETE}')
Sleep(500)
Send('http://weather.yahooapis.com/forecastrss?p=' & $Zip)
Send('{ENTER}')
WinWaitActive('Yahoo!')
If $status = 'Done' Then
EndIf
Sleep(500)
Send('^a')
Sleep(500)
Send('^c')
Send('!{F4}')
WinWaitClose('Internet Explorer')
FileWrite('C:\\Program Files\\MotoWeather\\WeatherData.txt', ClipGet())
$file = FileOpen('C:\\Program Files\\MotoWeather\\WeatherData.txt', 0)
$ForecastToday = FileReadLine($file, 26)
$ForecastTomorrow = FileReadLine($file, 27)
If $ForecastToday > $LowTemp Or $ForecastToday < $HighTemp Then
    MsgBox(0, 'Great Weather!', 'Go Riding!' & @CRLF & 'Your Max Temp' & @CRLF & $HighTemp & @CRLF & 'You Min Temp' & @CRLF & $LowTemp & @CRLF & @CRLF & $ForecastToday & @CRLF & $ForecastTomorrow)
ElseIf $ForecastToday <= $LowTemp Or $ForecastToday >= $HighTemp Then
    MsgBox(0, 'Bad Weather', 'Fuck That!' & @CRLF & 'Your Max Temp' & @CRLF & $HighTemp & @CRLF & 'You Min Temp' & @CRLF & $LowTemp & @CRLF & @CRLF & $ForecastToday & @CRLF & $ForecastTomorrow)
EndIf
FileClose($file)
FileDelete('C:\\Program Files\\MotoWeather\\WeatherData.txt')
Exit

Thanks

Link to comment
Share on other sites

Ok just a few hints/tips.

1. When you are using the path and you use "\\" I don't think it's necessary to use two, but I'm not 100% on that one.

2. When you use the status bar you are only checking to see what the status is once then it continues with the program regardless of whether or not it's done. You might try this instead:

Do
    $status = StatusbarGetText("Internet Explorer")
    sleep(250)
Until $status = "Done"oÝ÷ Ûu¡z|¨»§¶Ú(¥éÚqêíj)éj«jØ^®ØZë"¥·çZ×-®_ʦmÁ©í¶)zx­ºb­ç-+¬x-+ºÚ"µÍ[ ][ÝÐÎÌLÔÙÜ[H[ÉÌLÒ[]^ÜÌLÚY^ÜK^H    ][ÝÈ  [È ][ÝÚËÝÙX]XZÛØËÛÛKÙÜXØÝÜÏÜI][ÝÈ   [È ÌÍÖ  ][ÝÉ][ÝËÕ×ÒQJ

Those are my suggestions, but as I cannot open yahoo at work I can't test it, but I hope that helps. :)

Link to comment
Share on other sites

thank you so much, I will try them now and see how it works. I used the \\ from version 2. Wasn't sure it was necessary in v3

EDIT:

Gave it shot and they both coeds you posted work very well thank you! I'll post the updated code. I have no clue on how to use the Do Until commands, i read the help file but sometimes the stuff just doesn't make sense to me.

I have a ton of questions...one being does the WinWaitDelay apply just once or throughout the whole code?

But my biggest problem is the actual msgbox at the end, i cant seem to make it check the saved values are BOTH Higher then the set low and lower than the set high. I can get either or, hence the or in the or here:

If $ForecastToday > $LowTemp Or $ForecastToday < $HighTemp Then

Full Updated Code:

If FileExists('C:\\Program Files\\MotoWeather\\Config.ini') Then

Else

DirCreate('C:\\Program Files\\MotoWeather')

$LowTemp = InputBox('Should You Ride Today?', 'Enter the LOWEST temperature (Fahrenheit) you would ride in')

$HighTemp = InputBox('Should You Ride Today?', 'Enter the HIGHEST temperature (Fahrenheit) you would ride in')

$Zip = InputBox('AutoIt', 'Enter your zip code')

IniWrite('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'Low', $LowTemp)

IniWrite('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'High', $HighTemp)

IniWrite('C:\\Program Files\\MotoWeather\\Config.ini', 'Zip', 'Code', $Zip)

EndIf

$Zip = IniRead('C:\\Program Files\\MotoWeather\\Config.ini', 'Zip', 'Code', "")

$LowTemp = IniRead('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'Low', "")

$HighTemp = IniRead('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'High', "")

Opt("WinWaitDelay", 250) ;250 milliseconds

Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

Run("C:\Program Files\Internet Explorer\iexplore.exe " & "http://weather.yahooapis.com/forecastrss?p=" & $Zip, "", @SW_HIDE)

WinWaitActive('Internet Explorer')

WinActivate('Internet Explorer')

Do

$status = StatusbarGetText("Internet Explorer")

sleep(250)

Until $status = "Done"

Sleep(500)

Send('^a')

Sleep(500)

Send('^c')

Send('!{F4}')

WinWaitClose('Internet Explorer')

FileWrite('C:\\Program Files\\MotoWeather\\WeatherData.txt', ClipGet())

$file = FileOpen('C:\\Program Files\\MotoWeather\\WeatherData.txt', 0)

$ForecastToday = FileReadLine($file, 26)

$ForecastTomorrow = FileReadLine($file, 27)

If $ForecastToday > $LowTemp Or $ForecastToday < $HighTemp Then

MsgBox(0, 'Great Weather!', 'Go Riding!' & @CRLF & 'Your Max Temp' & @CRLF & $HighTemp & @CRLF & 'You Min Temp' & @CRLF & $LowTemp & @CRLF & @CRLF & $ForecastToday & @CRLF & $ForecastTomorrow)

ElseIf $ForecastToday <= $LowTemp Or $ForecastToday >= $HighTemp Then

MsgBox(0, 'Bad Weather', 'Fuck That!' & @CRLF & 'Your Max Temp' & @CRLF & $HighTemp & @CRLF & 'You Min Temp' & @CRLF & $LowTemp & @CRLF & @CRLF & $ForecastToday & @CRLF & $ForecastTomorrow)

EndIf

FileClose($file)

FileDelete('C:\\Program Files\\MotoWeather\\WeatherData.txt')

Exit

Edited by onelowzx6r
Link to comment
Share on other sites

Do command:

Basically it means Do the commands between the "do" and "until" until the the expression is true. The expression being whatever you put right after the until, in your case $status = "Done". So it keeps checking the statusbartext of the window you want until it says done, with a sleep of 250 milliseconds.

WinWaitDelay sets that option for the entire length of the script, once the script ends it returns to the default.

Give me a few minutes to look over your code and I'll see if I notice anything.

Link to comment
Share on other sites

I see what the problem is you want to use AND instead of OR in the first If:

If FileExists('C:\\Program Files\\MotoWeather\\Config.ini') Then
Else
    DirCreate('C:\\Program Files\\MotoWeather')
    $LowTemp = InputBox('Should You Ride Today?', 'Enter the LOWEST temperature (Fahrenheit) you would ride in')
    $HighTemp = InputBox('Should You Ride Today?', 'Enter the HIGHEST temperature (Fahrenheit) you would ride in')
    $Zip = InputBox('AutoIt', 'Enter your zip code')
    IniWrite('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'Low', $LowTemp)
    IniWrite('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'High', $HighTemp)
    IniWrite('C:\\Program Files\\MotoWeather\\Config.ini', 'Zip', 'Code', $Zip)
EndIf
$Zip = IniRead('C:\\Program Files\\MotoWeather\\Config.ini', 'Zip', 'Code', "")
$LowTemp = IniRead('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'Low', "")
$HighTemp = IniRead('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'High', "")
Opt("WinWaitDelay", 250) ;250 milliseconds
Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Run("C:\Program Files\Internet Explorer\iexplore.exe " & "http://weather.yahooapis.com/forecastrss?p=" & $Zip, "", @SW_HIDE)
WinWaitActive('Internet Explorer')
WinActivate('Internet Explorer')
Do
$status = StatusbarGetText("Internet Explorer")
sleep(250)
Until $status = "Done"

Sleep(500)
Send('^a')
Sleep(500)
Send('^c')
Send('!{F4}')
WinWaitClose('Internet Explorer')
FileWrite('C:\\Program Files\\MotoWeather\\WeatherData.txt', ClipGet())
$file = FileOpen('C:\\Program Files\\MotoWeather\\WeatherData.txt', 0)
$ForecastToday = FileReadLine($file, 26)
$ForecastTomorrow = FileReadLine($file, 27)
If (($ForecastToday > $LowTemp) And ($ForecastToday < $HighTemp)) Then
MsgBox(0, 'Great Weather!', 'Go Riding!' & @CRLF & 'Your Max Temp' & @CRLF & $HighTemp & @CRLF & 'You Min Temp' & @CRLF & $LowTemp & @CRLF & @CRLF & $ForecastToday & @CRLF & $ForecastTomorrow)
ElseIf (($ForecastToday <= $LowTemp) Or ($ForecastToday >= $HighTemp)) Then
MsgBox(0, 'Bad Weather', 'Fuck That!' & @CRLF & 'Your Max Temp' & @CRLF & $HighTemp & @CRLF & 'You Min Temp' & @CRLF & $LowTemp & @CRLF & @CRLF & $ForecastToday & @CRLF & $ForecastTomorrow)
EndIf
FileClose($file)
FileDelete('C:\\Program Files\\MotoWeather\\WeatherData.txt')
Exit
Link to comment
Share on other sites

Ok I know what's going on. In $Forecast today it says "Mostly Sunny. High: 86 Low: 67" not just a number for the high and low. You need to break that up so it has more meaning. I couldn't see that before because it ran off my screen, and I can't test it at work. This is the change you need to add:

$ForecastToday = FileReadLine($file, 26)
$ForecastTomorrow = FileReadLine($file, 27)
$HighLoc = StringInStr( $ForecastToday, "High:") + 5
$LowLoc = StringInStr( $ForecastToday, "Low:")
$ForecastLength = StringLen( $ForecastToday )
$HighToday = StringMid( $ForecastToday, $HighLoc, (($LowLoc - 1) - $HighLoc) )
$LowToday = StringRight( $ForecastToday, ($ForecastLength - ($LowLoc + 4)) )
$HighToday = StringReplace( $HighToday, " ", "")
$LowToday = StringReplace( $LowToday, " ", "")
MsgBox(0, "Test", "HighToday: " & $HighToday & " LowToday: " & $LowToday)
If (($LowToday > $LowTemp) And ($HighToday < $HighTemp)) Then
MsgBox(0, 'Great Weather!', 'Go Riding!' & @CRLF & 'Your Max Temp' & @CRLF & $HighTemp & @CRLF & 'You Min Temp' & @CRLF & $LowTemp & @CRLF & @CRLF & $ForecastToday & @CRLF & $ForecastTomorrow)
ElseIf (($ForecastToday <= $LowTemp) Or ($ForecastToday >= $HighTemp)) Then
MsgBox(0, 'Bad Weather', 'Fuck That!' & @CRLF & 'Your Max Temp' & @CRLF & $HighTemp & @CRLF & 'You Min Temp' & @CRLF & $LowTemp & @CRLF & @CRLF & $ForecastToday & @CRLF & $ForecastTomorrow)
EndIf
Link to comment
Share on other sites

wow that works great! thanks. The last piece of the puzzle for me is determining if the "Conditions" are bad. Originally i had 4 different message boxes laid out like this:

1st box would reply:

Temp is in range and weather is looking good (the script was to check if "storm" or "snow" were in line 26 - see first post of this thread)

2nd box:

Temp in range but weather is bad

3rd box:

Temp out of range but weather good

4th box:

Temp out and weather out

Any suggestions on this?

BTW - Thanks so much for all your help, i would have NEVER gotten this far.

Link to comment
Share on other sites

Why did you make a duplicate topic?

http://www.autoitscript.com/forum/index.php?showtopic=73305

Anyways...I posted some code in that topic that uses the data from the RSS feed.

Sorry about the duplicate, it was so hard to read i didn't think anyone would even bother. I saw your post, and the major problem is I'm retarded. I tried to just copy and paste you code both into a new script. I don't have these files:

#include <_XMLDomWrapper.au3>

#include <Array.au3>

#include <INet.au3>

so it would return an error, and being an idiot to this stuff I didn't know what to do. cartman380's post did exactly what i wanted. I realize there is more to be done with my script and it probably looks like trash to you guys. But as a starter its motivation for me.

to be perfectly honest i have no "f"ing clue what your script does...(start flame wars now)...so it's not that i don't appreciate it i just don't understand it.

EDIT: I'm guessing your code breaks the RSS feed into specific sections so that my script could use them how i see fit? Just my guess though, again I'm not exactly what you'd call a coder. lol

Edited by onelowzx6r
Link to comment
Share on other sites

Sorry about the duplicate, it was so hard to read i didn't think anyone would even bother. I saw your post, and the major problem is I'm retarded. I tried to just copy and paste you code both into a new script. I don't have these files:

#include <_XMLDomWrapper.au3>

#include <Array.au3>

#include <INet.au3>

so it would return an error, and being an idiot to this stuff I didn't know what to do. cartman380's post did exactly what i wanted. I realize there is more to be done with my script and it probably looks like trash to you guys. But as a starter its motivation for me.

to be perfectly honest i have no "f"ing clue what your script does...(start flame wars now)...so it's not that i don't appreciate it i just don't understand it.

_XMLDomWrapper.au3 is found in Example Scripts:

http://www.autoitscript.com/forum/index.ph...9848&hl=xml

The other two files come with AutoIt.

The page which you are retrieving the weather info from is an RSS feed which is XML. The XML Wrapper can parse specific nodes from the feed.

Link to comment
Share on other sites

OK why wont it pick up the 'storms' part? see screenshot

If FileExists('C:\\Program Files\\MotoWeather\\Config.ini') Then
Else
    DirCreate('C:\\Program Files\\MotoWeather')
    $LowTemp = InputBox('Should You Ride Today?', 'Enter the LOWEST temperature (Fahrenheit) you would ride in')
    $HighTemp = InputBox('Should You Ride Today?', 'Enter the HIGHEST temperature (Fahrenheit) you would ride in')
    $Zip = InputBox('AutoIt', 'Enter your zip code')
    IniWrite('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'Low', $LowTemp)
    IniWrite('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'High', $HighTemp)
    IniWrite('C:\\Program Files\\MotoWeather\\Config.ini', 'Zip', 'Code', $Zip)
EndIf
$Zip = IniRead('C:\\Program Files\\MotoWeather\\Config.ini', 'Zip', 'Code', "")
$LowTemp = IniRead('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'Low', "")
$HighTemp = IniRead('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'High', "")
Opt("WinWaitDelay", 250);250 milliseconds
Opt("WinTitleMatchMode", 2);1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Run("C:\Program Files\Internet Explorer\iexplore.exe " & "http://weather.yahooapis.com/forecastrss?p=" & $Zip, "", @SW_HIDE)
WinWaitActive('Internet Explorer')
WinActivate('Internet Explorer')
Do
    $status = StatusbarGetText("Internet Explorer")
    Sleep(250)
Until $status = "Done"
Sleep(500)
Send('^a')
Sleep(500)
Send('^c')
Send('!{F4}')
WinWaitClose('Internet Explorer')
FileWrite('C:\\Program Files\\MotoWeather\\WeatherData.txt', ClipGet())
$file = FileOpen('C:\\Program Files\\MotoWeather\\WeatherData.txt', 0)
$ForecastToday = FileReadLine($file, 26)
$ForecastTomorrow = FileReadLine($file, 27)
$HighLoc = StringInStr($ForecastToday, "High:") + 5
$LowLoc = StringInStr($ForecastToday, "Low:")
$ForecastLength = StringLen($ForecastToday)
$HighToday = StringMid($ForecastToday, $HighLoc, (($LowLoc - 1) - $HighLoc))
$LowToday = StringRight($ForecastToday, ($ForecastLength - ($LowLoc + 4)))
$HighToday = StringReplace($HighToday, " ", "")
$LowToday = StringReplace($LowToday, " ", "")
MsgBox(0, "Test", "HighToday: " & $HighToday & " LowToday: " & $LowToday)
If ((($LowToday > $LowTemp) And ($HighToday < $HighTemp) And Not ($ForecastToday = 'Storms'))) Then
    MsgBox(0, 'Today Should Be A Great Ride!', 'Go Riding!' & @CRLF & 'Your Max Temp' & @CRLF & $HighTemp & @CRLF & 'You Min Temp' & @CRLF & $LowTemp & @CRLF & @CRLF & $ForecastToday & @CRLF & $ForecastTomorrow)
ElseIf ((($ForecastToday > $LowTemp) And ($ForecastToday < $HighTemp) And ($ForecastToday = 'Storms'))) Then
    MsgBox(0, 'CAUTION! - Bad Weather Predicted', 'Temp is in range but bad weather predicted' & @CRLF & 'Your Max Temp' & @CRLF & $HighTemp & @CRLF & 'You Min Temp' & @CRLF & $LowTemp & @CRLF & @CRLF & $ForecastToday & @CRLF & $ForecastTomorrow)
ElseIf ((($ForecastToday <= $LowTemp) Or ($ForecastToday >= $HighTemp) And Not ($ForecastToday = 'Storms'))) Then
    MsgBox(0, 'CAUTION! - Out of Temperature Range', 'Temp is out of range but weather is good' & @CRLF & 'Your Max Temp' & @CRLF & $HighTemp & @CRLF & 'You Min Temp' & @CRLF & $LowTemp & @CRLF & @CRLF & $ForecastToday & @CRLF & $ForecastTomorrow)
ElseIf ((($ForecastToday <= $LowTemp) Or ($ForecastToday >= $HighTemp) And ($ForecastToday = 'Storms'))) Then
    MsgBox(0, 'EXTEME CAUTION! - Riding Not Advised!', 'Temp is out of range and bad weather predicted' & @CRLF & 'Your Max Temp' & @CRLF & $HighTemp & @CRLF & 'You Min Temp' & @CRLF & $LowTemp & @CRLF & @CRLF & $ForecastToday & @CRLF & $ForecastTomorrow)
EndIf
FileClose($file)
FileDelete('C:\\Program Files\\MotoWeather\\WeatherData.txt')
Exit

Posted Image

Edited by onelowzx6r
Link to comment
Share on other sites

i just updated to add a progress bar, although i'm sure its not showing shit. Its just a visual really...

i also have other issues (see previous post)

If FileExists('C:\\Program Files\\MotoWeather\\Config.ini') Then
Else
    DirCreate('C:\\Program Files\\MotoWeather')
    $LowTemp = InputBox('Should You Ride Today?', 'Enter the LOWEST temperature (Fahrenheit) you would ride in')
    $HighTemp = InputBox('Should You Ride Today?', 'Enter the HIGHEST temperature (Fahrenheit) you would ride in')
    $Zip = InputBox('AutoIt', 'Enter your zip code')
    IniWrite('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'Low', $LowTemp)
    IniWrite('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'High', $HighTemp)
    IniWrite('C:\\Program Files\\MotoWeather\\Config.ini', 'Zip', 'Code', $Zip)
EndIf
ProgressOn("MotoWeather", "Checking Weather...", "0%")
For $i = 100 to 100 step 100
$Zip = IniRead('C:\\Program Files\\MotoWeather\\Config.ini', 'Zip', 'Code', "")
$LowTemp = IniRead('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'Low', "")
$HighTemp = IniRead('C:\\Program Files\\MotoWeather\\Config.ini', 'TempLimits', 'High', "")
Opt("WinWaitDelay", 250);250 milliseconds
Opt("WinTitleMatchMode", 2);1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Run("C:\Program Files\Internet Explorer\iexplore.exe " & "http://weather.yahooapis.com/forecastrss?p=" & $Zip, "", @SW_HIDE)
WinWaitActive('Internet Explorer')
WinActivate('Internet Explorer')
Do
    $status = StatusbarGetText("Internet Explorer")
    Sleep(250)
Until $status = "Done"
Sleep(500)
Send('^a')
Sleep(500)
Send('^c')
Send('!{F4}')
WinWaitClose('Internet Explorer')
FileWrite('C:\\Program Files\\MotoWeather\\WeatherData.txt', ClipGet())
$file = FileOpen('C:\\Program Files\\MotoWeather\\WeatherData.txt', 0)
$ForecastToday = FileReadLine($file, 26)
$ForecastTomorrow = FileReadLine($file, 27)
$HighLoc = StringInStr($ForecastToday, "High:") + 5
$LowLoc = StringInStr($ForecastToday, "Low:")
$ForecastLength = StringLen($ForecastToday)
$HighToday = StringMid($ForecastToday, $HighLoc, (($LowLoc - 1) - $HighLoc))
$LowToday = StringRight($ForecastToday, ($ForecastLength - ($LowLoc + 4)))
$HighToday = StringReplace($HighToday, " ", "")
$LowToday = StringReplace($LowToday, " ", "")
ProgressSet( $i, $i & " percent")
Next
ProgressSet(100 , "100%", "Complete")
sleep(500)
ProgressOff()
MsgBox(0, "Current Weather", "HighToday: " & $HighToday & " LowToday: " & $LowToday)
If ((($LowToday > $LowTemp) And ($HighToday < $HighTemp) And Not ($ForecastToday = 'Storms'))) Then
    MsgBox(0, 'Today Should Be A Great Ride!', 'Go Riding!' & @CRLF & 'Your Max Temp' & @CRLF & $HighTemp & @CRLF & 'You Min Temp' & @CRLF & $LowTemp & @CRLF & @CRLF & $ForecastToday & @CRLF & $ForecastTomorrow)
ElseIf ((($ForecastToday > $LowTemp) And ($ForecastToday < $HighTemp) And ($ForecastToday = 'Storms'))) Then
    MsgBox(0, 'CAUTION! - Bad Weather Predicted', 'Temp is in range but bad weather predicted' & @CRLF & 'Your Max Temp' & @CRLF & $HighTemp & @CRLF & 'You Min Temp' & @CRLF & $LowTemp & @CRLF & @CRLF & $ForecastToday & @CRLF & $ForecastTomorrow)
ElseIf ((($ForecastToday <= $LowTemp) Or ($ForecastToday >= $HighTemp) And Not ($ForecastToday = 'Storms'))) Then
    MsgBox(0, 'CAUTION! - Out of Temperature Range', 'Temp is out of range but weather is good' & @CRLF & 'Your Max Temp' & @CRLF & $HighTemp & @CRLF & 'You Min Temp' & @CRLF & $LowTemp & @CRLF & @CRLF & $ForecastToday & @CRLF & $ForecastTomorrow)
ElseIf ((($ForecastToday <= $LowTemp) Or ($ForecastToday >= $HighTemp) And ($ForecastToday = 'Storms'))) Then
    MsgBox(0, 'EXTEME CAUTION! - Riding Not Advised!', 'Temp is out of range and bad weather predicted' & @CRLF & 'Your Max Temp' & @CRLF & $HighTemp & @CRLF & 'You Min Temp' & @CRLF & $LowTemp & @CRLF & @CRLF & $ForecastToday & @CRLF & $ForecastTomorrow)
EndIf
FileClose($file)
FileDelete('C:\\Program Files\\MotoWeather\\WeatherData.txt')
Exit
Link to comment
Share on other sites

Ok same problem, you need to split up ForecastToday so that it gets the weather as well. Just like having to search for the High: and Low: to grab the temperature, you need to do a search for "storm" or "snow". Also, you don't need a for loop for a progress bar if you're only doing something once, you only need a for loop if you doing something similar using different variables or the same thing a certain number of times I just picked arbitrary numbers to represent percentage. I also commmented everything I've added so you can see what's happening at each step. see the code below

$ForecastToday = FileReadLine($file, 26) ; Format of ForecastToday: <Day> - <Weather>. High: <high temp> Low: <low temp>
$ForecastTomorrow = FileReadLine($file, 27)
$HighLoc = StringInStr($ForecastToday, "High:") + 5 ; Get location of "High:" in ForecastToday string
$LowLoc = StringInStr($ForecastToday, "Low:") ; Get location of "Low:" in ForecastToday string
$ForecastLength = StringLen($ForecastToday) ; Get ForecastToday Length
$HighToday = StringMid($ForecastToday, $HighLoc, (($LowLoc - 1) - $HighLoc)) ; Get the high temperature by extracting everything between where High: ends and Low: begins
$LowToday = StringRight($ForecastToday, ($ForecastLength - ($LowLoc + 4))) ; Get the low temperature by grabbing everything to the right of the end Low:
$HighToday = StringReplace($HighToday, " ", "") ; Remove any blank spaces from high temperature variable
$LowToday = StringReplace($LowToday, " ", "") ; Remove any blank spaces from low temperature variable
$ForecastStorm = StringInStr( $ForecastToday, "storm", 0) ; Check for "storm" using the "0" flag making it case insensitive
If ($ForecastStorm = 0) Then $ForecastStorm = StringInStr( $ForecastToday, "snow", 0) ; Check for "snow" using the "0" flag making it case insensitive
ProgressSet(100 , "100%", "Complete")
sleep(500)
ProgressOff()
If ((($LowToday > $LowTemp) And ($HighToday < $HighTemp) And ($ForecastStorm = 0))) Then
    MsgBox(0, 'Today Should Be A Great Ride!', 'Go Riding!' & @CRLF & 'Your Max Temp' & @CRLF & $HighTemp & @CRLF & 'You Min Temp' & @CRLF & $LowTemp & @CRLF & @CRLF & $ForecastToday & @CRLF & $ForecastTomorrow)
ElseIf ((($ForecastToday > $LowTemp) And ($ForecastToday < $HighTemp) And ($ForecastStorm > 0))) Then
    MsgBox(0, 'CAUTION! - Bad Weather Predicted', 'Temp is in range but bad weather predicted' & @CRLF & 'Your Max Temp' & @CRLF & $HighTemp & @CRLF & 'You Min Temp' & @CRLF & $LowTemp & @CRLF & @CRLF & $ForecastToday & @CRLF & $ForecastTomorrow)
ElseIf (((($ForecastToday <= $LowTemp) Or ($ForecastToday >= $HighTemp)) And ($ForecastStorm = 0))) Then
    MsgBox(0, 'CAUTION! - Out of Temperature Range', 'Temp is out of range but weather is good' & @CRLF & 'Your Max Temp' & @CRLF & $HighTemp & @CRLF & 'You Min Temp' & @CRLF & $LowTemp & @CRLF & @CRLF & $ForecastToday & @CRLF & $ForecastTomorrow)
ElseIf (((($ForecastToday <= $LowTemp) Or ($ForecastToday >= $HighTemp)) And ($ForecastStorm > 0))) Then
    MsgBox(0, 'EXTEME CAUTION! - Riding Not Advised!', 'Temp is out of range and bad weather predicted' & @CRLF & 'Your Max Temp' & @CRLF & $HighTemp & @CRLF & 'You Min Temp' & @CRLF & $LowTemp & @CRLF & @CRLF & $ForecastToday & @CRLF & $ForecastTomorrow)
EndIf
FileClose($file)
FileDelete('C:\\Program Files\\MotoWeather\\WeatherData.txt')
Exit
Edited by cartman380
Link to comment
Share on other sites

ok i see i see! wow you sir are a god send! I'll be sure to give you credit it the notes of this thing. Thanks for the comments to that helps a lot. I try to get as much info as i can from he help file, but sometimes the fact that an explanation references some other input I don't understand...well that makes it a bit difficult.

I will be adding a few more weather conditions (snow, fog, tornado, etc.) - thanks to you i can look at how "storm" was entered and go from there.

Thank you so much both for you quick replies and doing most of the leg work!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...