onelowzx6r Posted June 12, 2008 Posted June 12, 2008 here is the code (thanks to cartman380) and although i sent him a barrage of messages, maybe you guys could hit it sooner. I would like to another substring "read" i guess its called but i don't know how...cartman380 does...but alas. I tried adding and exact copy of this, just replacing all the "storm"s with "snow"s but that didn't work, and i tried a whole nother set of msgboxs but that obviously wont work because its going to pick the first true. Basically it works great now (again thanks to cartman380), but i would like to add more weather conditions (snow, rain, fog, etc.) I'm fairly retarded with this so I'll let you know up front I'll need some explanation, otherwise i won't learn. so what do i do? here is the code im trying to replicate: $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, "storm", 0); Check for "storm" 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 ((($LowToday > $LowTemp) And ($HighToday < $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 (((($LowToday <= $LowTemp) Or ($HighToday >= $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 (((($LowToday <= $LowTemp) Or ($HighToday >= $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 Whole Code: expandcollapse popupIf 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) IniWrite('C:\\Program Files\\MotoWeather\\Config.ini', 'Edit', 'Save', 'IF YOU CHANGE PROPERTIES - YOU MUST SAVE FILE BEFORE CLOSING!!!!') EndIf ProgressOn("MotoWeather", "Checking Weather...", "0%") $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', "") ProgressSet( 10, 10, "Checking Weather..."); progress at guessed 10% 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') ProgressSet( 40, 40, "Checking Weather..."); progress at guessed 40% Do $status = StatusbarGetText("Internet Explorer") Sleep(250) Until $status = "Done" WinActivate('Internet Explorer') Sleep(500) Send('^a') Sleep(500) Send('^c') ProgressSet( 80, 80, "Checking Weather..."); progress at guessed 80% WinClose('Internet Explorer') WinWaitClose('Internet Explorer') FileWrite('C:\\Program Files\\MotoWeather\\WeatherData.txt', ClipGet()) $file = FileOpen('C:\\Program Files\\MotoWeather\\WeatherData.txt', 0) $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, "storm", 0); Check for "storm" 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 ((($LowToday > $LowTemp) And ($HighToday < $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 (((($LowToday <= $LowTemp) Or ($HighToday >= $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 (((($LowToday <= $LowTemp) Or ($HighToday >= $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
cartman380 Posted June 12, 2008 Posted June 12, 2008 All you have to do is add more variables one called ForecastSnow, ForecastRain etc whatever you want. Then in the If statement change it to the following. FYI busy day today haven't had a chance to check the forum till now $file = FileOpen('C:\\Program Files\\MotoWeather\\WeatherData.txt', 0) $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 $ForecastSnow = 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) And ($ForecastSnow = 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 (($LowToday > $LowTemp) And ($HighToday < $HighTemp) And (($ForecastStorm > 0) Or ($ForecastSnow > 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 ((($LowToday <= $LowTemp) Or ($HighToday >= $HighTemp)) And ($ForecastStorm = 0) And ($ForecastSnow = 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 ((($LowToday <= $LowTemp) Or ($HighToday >= $HighTemp)) And (($ForecastStorm > 0) Or ($ForecastSnow > 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now