Announcement

Collapse
No announcement yet.

Script Help!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    I wouldn't think the ini file would be simpler. Let me cut and paste your code and try to run it on my computer to see what is up.
    James

    Running HS 3 on Win10 .

    Comment


      #17
      Originally posted by nightwalker View Post
      Interesting, I didn't know you could combine the "dim s as string =hs.DeviceString("#10")
      " into one line. It got me past the Name not declared error and give me an expression error. "Script compile error: Expression is not a method.on line 22"
      Marty

      Now that you're nearly a script expert you might want to consider installing the VB Express compiler. It's free from MS (just do a quick google for it).

      It will help you identify many of the errors you are seeing before you even run the script within HS.

      Cheers
      Nicolai
      Nicolai L

      Comment


        #18
        Originally posted by NicolaiL View Post
        Marty

        Now that you're nearly a script expert you might want to consider installing the VB Express compiler. It's free from MS (just do a quick google for it).

        It will help you identify many of the errors you are seeing before you even run the script within HS.

        Cheers
        Nicolai
        Believe it or not I had that installed at one point, After a rebuild I never did re-install it and since up to this point all my scripts were pretty simple I never got around to it. This so far is my most complicated script by far (stop that laughing, i can almost hear you from here). Really good suggestion and I'll take it!
        Marty
        ------
        XPpro SP3 /w HS Standard 2.5.0.80, HSTouch Server - 1.0.0.70, HSTouch Client 1.0.0.73 HSTouch Android - 1.0.0.2, HSTouch iPhone - 1.0.0.2
        Playing with HS3 a bit but it's just play at this point.

        Comment


          #19
          Originally posted by jasv View Post
          I wouldn't think the ini file would be simpler. Let me cut and paste your code and try to run it on my computer to see what is up.
          Thanks for taking a look, as you can see i'm way out of my comfort zone here.
          Marty
          ------
          XPpro SP3 /w HS Standard 2.5.0.80, HSTouch Server - 1.0.0.70, HSTouch Client 1.0.0.73 HSTouch Android - 1.0.0.2, HSTouch iPhone - 1.0.0.2
          Playing with HS3 a bit but it's just play at this point.

          Comment


            #20
            Are you running this as vb script? Meaning does it have a .vb suffix or a .txt suffix. I started to work on it as .txt but I notice most of the syntax is vb.
            James

            Running HS 3 on Win10 .

            Comment


              #21
              If you are running this as a .vb script the following should work. Let me know if it doesn't.

              I tried it and it worked on my computer
              Code:
                  Public Function CommonProc() As String
              
                      Dim s As String = hs.DeviceString("#10")
                      Dim thisMsg As String = ""
                      '------------------------------------------------------------------------------ 
                      If s = "Cloudy" Then
                          thisMsg = hs.Plugin("BLRandom").RandomizeGroup("BLW-Cloudy-Cold")
                      ElseIf s = "Fair" Then
                          thisMsg = hs.Plugin("BLRandom").RandomizeGroup("BLW-Fair-Cold")
                      ElseIf s = "Sunny" Then
                          thisMsg = hs.Plugin("BLRandom").RandomizeGroup("BLW-Sunny-Cold")
                      ElseIf s = "Unknown Precip" Then
                          thisMsg = hs.Plugin("BLRandom").RandomizeGroup("BLW-Unknown")
                      End If
                      Return thisMsg
              
                      '------------------------------------------------------------------------------ 
              
                  End Function
              
                  Public Sub Option1(ByVal Parms As Object)
              
                      Dim speakMsg 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 ")
              
              
                      hs.Speak(speakMsg & CommonProc(), True)
                      speakMsg = Nothing
              
                  End Sub
              
                  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
              James

              Running HS 3 on Win10 .

              Comment


                #22
                yes, i run it as a vb script. Seeing how some of the syntax is .txt that could explain the error?
                Marty
                ------
                XPpro SP3 /w HS Standard 2.5.0.80, HSTouch Server - 1.0.0.70, HSTouch Client 1.0.0.73 HSTouch Android - 1.0.0.2, HSTouch iPhone - 1.0.0.2
                Playing with HS3 a bit but it's just play at this point.

                Comment


                  #23
                  Yes. I would have expected a better error message but...
                  James

                  Running HS 3 on Win10 .

                  Comment


                    #24
                    That worked, now I can go finish it. Thank you very much.

                    I see my problem was I ended a function with an end sub instead of an end function. Duh!!!!!

                    Again, thanks to everyone for the bits of education.
                    Marty
                    ------
                    XPpro SP3 /w HS Standard 2.5.0.80, HSTouch Server - 1.0.0.70, HSTouch Client 1.0.0.73 HSTouch Android - 1.0.0.2, HSTouch iPhone - 1.0.0.2
                    Playing with HS3 a bit but it's just play at this point.

                    Comment


                      #25
                      Originally posted by nightwalker View Post
                      That worked, now I can go finish it. Thank you very much.

                      I see my problem was I ended a function with an end sub instead of an end function. Duh!!!!!

                      Again, thanks to everyone for the bits of education.
                      Hey Marty

                      One final point; now that you are considering installing VB Express you should really consider perfecting your 'development environment' with tenholde's script compiler. It means you can run and debug scripts straight from the VB compiler and test them against your live HS instance. Once you are satisfied they are working you simply export them and the finished product sits in your HS\scripts directory.

                      Good luck...

                      Nicolai
                      Nicolai L

                      Comment


                        #26
                        Yeah, I had that installed at one point too At my last machine rebuild had so much junk on it that I decided to install things as I needed them. This was the first time I could have used them and to be honest I didn't think i'd need them for this little thing. When I'm wrong, I'm wrong big time.
                        Marty
                        ------
                        XPpro SP3 /w HS Standard 2.5.0.80, HSTouch Server - 1.0.0.70, HSTouch Client 1.0.0.73 HSTouch Android - 1.0.0.2, HSTouch iPhone - 1.0.0.2
                        Playing with HS3 a bit but it's just play at this point.

                        Comment


                          #27
                          Just curious

                          I am not familiar with Blade's Random plugin. What does do for you in this script?
                          James

                          Running HS 3 on Win10 .

                          Comment


                            #28
                            BLRandom does an amazing job of making my TTS announcements much more life like. Instead of setting up a TTS announcement that says the same thing every time I can set it up with many phrases that get chosen at random. I have a lot of TTS going on and I noticed the family would pretty much tune it out after hearing the same exact announcement everytime. This particular script is one that tells my wife that it's cold out and she might want to warm up the car before she leaves. BLRandom lets me tell her that in 25 different ways, picked at random by calling the plug-in, so things don't get stale. It also gives her the current weather conditions outside and reminds her to take an umbrella if it's raining, etc. Different things for different conditions and temperatures, all run through the plug-in so the phrases get switched around all the time and stay fresh.

                            It's been a real WAF booster here.

                            BTW I have to tell you I've never used the options in scripts before. I can see where this could be very useful in some circumstances. I appreciate the help with it.
                            Marty
                            ------
                            XPpro SP3 /w HS Standard 2.5.0.80, HSTouch Server - 1.0.0.70, HSTouch Client 1.0.0.73 HSTouch Android - 1.0.0.2, HSTouch iPhone - 1.0.0.2
                            Playing with HS3 a bit but it's just play at this point.

                            Comment


                              #29
                              Very cool tool. Thanks for the explanation. I am glad I could help. I've learned so much from everyone on this forum also that is nice to help out.
                              James

                              Running HS 3 on Win10 .

                              Comment


                                #30
                                This is probably the wrong place to ask this and the question if probably more complicated than I think but anyway, here goes.

                                Can someone, without getting way to technical, tell me the difference between a "Sub Main" and a "Public Sub Main"?
                                Marty
                                ------
                                XPpro SP3 /w HS Standard 2.5.0.80, HSTouch Server - 1.0.0.70, HSTouch Client 1.0.0.73 HSTouch Android - 1.0.0.2, HSTouch iPhone - 1.0.0.2
                                Playing with HS3 a bit but it's just play at this point.

                                Comment

                                Working...
                                X