I have a script that runs as part of my wife's morning routine. It does very well and has been running great for a while now. I have four different scripts that can be called, depending on the day and temperature. My problem is it's starting to get a bit unwieldy. What I'm trying to do is to lift out the section that is between the dashes and put that into an ini file to be read by any of the four scripts, since that part is identical. This will make it much easier to keep track of since I'll only have one ini file to maintain, instead of every change having to be made on four different scripts.
Can anyone help someone who knows just enough to be dangerous with scripts?
Can anyone help someone who knows just enough to be dangerous with scripts?
PHP Code:
Public Sub Main(ByVal Parms As Object)
Dim speakMsg As String = ""
Dim s as string
speakMsg = speakMsg & ("Cynthia, the temperature is " & hs.DeviceValue("Z3") & " degrees this " & TimeOfDay())
speakMsg = speakMsg & (" . ")
speakMsg = speakMsg & hs.Plugin("BLRandom").RandomizeGroup("Warm Car")
speakMsg = speakMsg & (" . . ")
speakMsg = speakMsg & (". Right now we have ")
speakMsg = speakMsg & hs.DeviceString("#10")
speakMsg = speakMsg & (" conditions outside. ")
speakMsg = speakMsg & (" . ")
speakMsg = speakMsg.Replace("Precip", "Precipatation ")
'------------------------------------------------------------------------------
s=hs.DeviceString("#10")
if s ="Cloudy" then
speakMsg = speakMsg & hs.Plugin("BLRandom").RandomizeGroup("BLW-Cloudy-Cold")
elseif s ="Mostly Cloudy" then
speakMsg = speakMsg & hs.Plugin("BLRandom").RandomizeGroup("BLW-Cloudy-Cold")
elseif s ="Partly Cloudy" then
speakMsg = speakMsg & hs.Plugin("BLRandom").RandomizeGroup("BLW-Cloudy-Cold")
elseif s ="Cloudy and Windy" then
speakMsg = speakMsg & hs.Plugin("BLRandom").RandomizeGroup("BLW-Cloudy-Windy-Cold")
elseif s ="Fair" then
speakMsg = speakMsg & hs.Plugin("BLRandom").RandomizeGroup("BLW-Fair-Cold")
elseif s ="Sunny" then
speakMsg = speakMsg & hs.Plugin("BLRandom").RandomizeGroup("BLW-Sunny-Cold")
elseif s ="Light Rain" then
speakMsg = speakMsg & hs.Plugin("BLRandom").RandomizeGroup("BLW-Rain-Cold")
elseif s ="Heavy Rain" then
speakMsg = speakMsg & hs.Plugin("BLRandom").RandomizeGroup("BLW-Rain-Cold")
elseif s ="Rain" then
speakMsg = speakMsg & hs.Plugin("BLRandom").RandomizeGroup("BLW-Rain-Cold")
elseif s ="Light Rain and Windy" then
speakMsg = speakMsg & hs.Plugin("BLRandom").RandomizeGroup("BLW-Rain-Cold")
elseif s ="Fog" then
speakMsg = speakMsg & hs.Plugin("BLRandom").RandomizeGroup("BLW-Fog")
elseif s ="Wintry Mix" then
speakMsg = speakMsg & hs.Plugin("BLRandom").RandomizeGroup("BLW-Wintry Mix")
elseif s ="Light Snow" then
speakMsg = speakMsg & hs.Plugin("BLRandom").RandomizeGroup("BLW-Light Snow")
elseif s ="Unknown Precip" then
speakMsg = speakMsg & hs.Plugin("BLRandom").RandomizeGroup("BLW-Unknown")
end if
'------------------------------------------------------------------------------
hs.Speak(speakMsg, True)
speakMsg = Nothing
End Sub
Function myTime() As String
Return Now.ToString("h:mm tt").Replace("PM", "P.M.").Replace("AM", "A.M.").Replace(":0", ", o")
End Function
Function TimeOfDay() As String
Select Case Now.Hour
Case Is < 12
Return "Morning"
Case 12 To 17
Return "Afternoon"
Case 18 To 24
Return "Evening"
Case Else
Return "Error"
End Select
End Function
Comment