Announcement

Collapse
No announcement yet.

Scripting Help

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

    Scripting Help

    I have the following script that was working but now I am getting errors. The script is Set_Current_Day_of_Month_to_Speak.vb

    Sub Main(parm as object)

    If hs.DeviceValueEx(125) = 1 Then hs.SetDeviceString(124,"First", True)
    Elseif hs.DeviceValueEx(125) = 2 Then hs.SetDeviceString(124,"Second", True)
    Elseif hs.DeviceValueEx(125) = 3 Then hs.SetDeviceStringe(124,"Third", True)
    Elseif hs.DeviceValueEx(125) = 4 Then hs.SetDeviceString(124,"Forth", True)
    Elseif hs.DeviceValueEx(125) = 5 Then hs.SetDeviceString(124,"Fifth", True)
    Elseif hs.DeviceValueEx(125) = 6 Then hs.SetDeviceString(124,"Sixth", True)
    Elseif hs.DeviceValueEx(125) = 7 Then hs.SetDeviceString(124,"Seventh", True)
    Elseif hs.DeviceValueEx(125) = 8 Then hs.SetDeviceString(124,"Eighth", True)
    Elseif hs.DeviceValueEx(125) = 9 Then hs.SetDeviceString(124,"Ninth", True)
    Elseif hs.DeviceValueEx(125) = 10 Then hs.SetDeviceString(124,"Tenth", True)
    Elseif hs.DeviceValueEx(125) = 11 Then hs.SetDeviceString(124,"Eleventh", True)
    Elseif hs.DeviceValueEx(125) = 12 Then hs.SetDeviceString(124,"Twelth", True)
    Elseif hs.DeviceValueEx(125) = 13 Then hs.SetDeviceString(124,"Thirt-teenth", True)
    Elseif hs.DeviceValueEx(125) = 14 Then hs.SetDeviceString(124,"Four-teenth", True)
    Elseif hs.DeviceValueEx(125) = 15 Then hs.SetDeviceString(124,"Fifth-teenth", True)
    Elseif hs.DeviceValueEx(125) = 16 Then hs.SetDeviceString(124,"Six-teenth", True)
    Elseif hs.DeviceValueEx(125) = 17 Then hs.SetDeviceString(124,"Seven-teenth", True)
    Elseif hs.DeviceValueEx(125) = 18 Then hs.SetDeviceString(124,"Eight-teenth", True)
    Elseif hs.DeviceValueEx(125) = 19 Then hs.SetDeviceString(124,"Nine-teenth", True)
    Elseif hs.DeviceValueEx(125) = 20 Then hs.SetDeviceString(124,"Twentieth", True)
    Elseif hs.DeviceValueEx(125) = 21 Then hs.SetDeviceString(124,"Twenty-first", True)
    Elseif hs.DeviceValueEx(125) = 22 Then hs.SetDeviceString(124,"Twenty-second", True)
    Elseif hs.DeviceValueEx(125) = 23 Then hs.SetDeviceString(124,"Twenty-third", True)
    Elseif hs.DeviceValueEx(125) = 24 Then hs.SetDeviceString(124,"Twenty-fourth", True)
    Elseif hs.DeviceValueEx(125) = 25 Then hs.SetDeviceString(124,"Twenty-fifth", True)
    Elseif hs.DeviceValueEx(125) = 26 Then hs.SetDeviceString(124,"Twenty-sixth", True)
    Elseif hs.DeviceValueEx(125) = 27 Then hs.SetDeviceString(124,"Twenty-seventh", True)
    Elseif hs.DeviceValueEx(125) = 28 Then hs.SetDeviceString(124,"Twenty-eighth", True)
    Elseif hs.DeviceValueEx(125) = 29 Then hs.SetDeviceString(124,"Twenty-ninth", True)
    Elseif hs.DeviceValueEx(125) = 30 Then hs.SetDeviceString(124,"Thirtieth", True)
    Elseif hs.DeviceValueEx(125) = 31 Then hs.SetDeviceString(124,"Thirty-first", True)

    End if

    End Sub

    The error is:

    Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\Set_Current_Day_of_Month_to_Speak.vb: Namespace or type specified in the Imports 'System.Core' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.

    Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\Set_Current_Day_of_Month_to_Speak.vb: 'End If' must be preceded by a matching 'If'.
    Nov-08 6:43:11 AM Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\Set_Current_Day_of_Month_to_Speak.vb: 'ElseIf' must be preceded by a matching 'If' or 'ElseIf'

    Thank you for any help with this.
    Last edited by sonypoolplr; November 8, 2017, 07:12 AM.

    #2
    Originally posted by sonypoolplr View Post
    I have the following script that was working but now I am getting errors. The script is Set_Current_Day_of_Month_to_Speak.vb

    Sub Main(parm as object)

    If hs.DeviceValueEx(125) = 1 Then hs.SetDeviceString(124,"First", True)
    Elseif hs.DeviceValueEx(125) = 2 Then hs.SetDeviceString(124,"Second", True)
    Elseif hs.DeviceValueEx(125) = 3 Then hs.SetDeviceStringe(124,"Third", True)
    Elseif hs.DeviceValueEx(125) = 4 Then hs.SetDeviceString(124,"Forth", True)
    Elseif hs.DeviceValueEx(125) = 5 Then hs.SetDeviceString(124,"Fifth", True)
    Elseif hs.DeviceValueEx(125) = 6 Then hs.SetDeviceString(124,"Sixth", True)
    Elseif hs.DeviceValueEx(125) = 7 Then hs.SetDeviceString(124,"Seventh", True)
    Elseif hs.DeviceValueEx(125) = 8 Then hs.SetDeviceString(124,"Eighth", True)
    Elseif hs.DeviceValueEx(125) = 9 Then hs.SetDeviceString(124,"Ninth", True)
    Elseif hs.DeviceValueEx(125) = 10 Then hs.SetDeviceString(124,"Tenth", True)
    Elseif hs.DeviceValueEx(125) = 11 Then hs.SetDeviceString(124,"Eleventh", True)
    Elseif hs.DeviceValueEx(125) = 12 Then hs.SetDeviceString(124,"Twelth", True)
    Elseif hs.DeviceValueEx(125) = 13 Then hs.SetDeviceString(124,"Thirt-teenth", True)
    Elseif hs.DeviceValueEx(125) = 14 Then hs.SetDeviceString(124,"Four-teenth", True)
    Elseif hs.DeviceValueEx(125) = 15 Then hs.SetDeviceString(124,"Fifth-teenth", True)
    Elseif hs.DeviceValueEx(125) = 16 Then hs.SetDeviceString(124,"Six-teenth", True)
    Elseif hs.DeviceValueEx(125) = 17 Then hs.SetDeviceString(124,"Seven-teenth", True)
    Elseif hs.DeviceValueEx(125) = 18 Then hs.SetDeviceString(124,"Eight-teenth", True)
    Elseif hs.DeviceValueEx(125) = 19 Then hs.SetDeviceString(124,"Nine-teenth", True)
    Elseif hs.DeviceValueEx(125) = 20 Then hs.SetDeviceString(124,"Twentieth", True)
    Elseif hs.DeviceValueEx(125) = 21 Then hs.SetDeviceString(124,"Twenty-first", True)
    Elseif hs.DeviceValueEx(125) = 22 Then hs.SetDeviceString(124,"Twenty-second", True)
    Elseif hs.DeviceValueEx(125) = 23 Then hs.SetDeviceString(124,"Twenty-third", True)
    Elseif hs.DeviceValueEx(125) = 24 Then hs.SetDeviceString(124,"Twenty-fourth", True)
    Elseif hs.DeviceValueEx(125) = 25 Then hs.SetDeviceString(124,"Twenty-fifth", True)
    Elseif hs.DeviceValueEx(125) = 26 Then hs.SetDeviceString(124,"Twenty-sixth", True)
    Elseif hs.DeviceValueEx(125) = 27 Then hs.SetDeviceString(124,"Twenty-seventh", True)
    Elseif hs.DeviceValueEx(125) = 28 Then hs.SetDeviceString(124,"Twenty-eighth", True)
    Elseif hs.DeviceValueEx(125) = 29 Then hs.SetDeviceString(124,"Twenty-ninth", True)
    Elseif hs.DeviceValueEx(125) = 30 Then hs.SetDeviceString(124,"Thirtieth", True)
    Elseif hs.DeviceValueEx(125) = 31 Then hs.SetDeviceString(124,"Thirty-first", True)

    End if

    End Sub

    The error is:

    Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\Set_Current_Day_of_Month_to_Speak.vb: Namespace or type specified in the Imports 'System.Core' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.

    Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\Set_Current_Day_of_Month_to_Speak.vb: 'End If' must be preceded by a matching 'If'.
    Nov-08 6:43:11 AM Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\Set_Current_Day_of_Month_to_Speak.vb: 'ElseIf' must be preceded by a matching 'If' or 'ElseIf'

    Thank you for any help with this.
    Try putting an "else" before the "end if"
    sigpic
    A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

    Comment


      #3
      What is the value of the device? Is it in the range 1-31?
      I agree with Gordon's suggestion. If you add
      Else hs.SetDeviceString(124,"???", True)
      after the last Elseif, then the script will handle the case where the device value is not a reasonable date.

      If that doesn't solve the problem, you could also try splitting this line:
      If hs.DeviceValueEx(125) = 1 Then hs.SetDeviceString(124,"First", True)
      to look like:
      If hs.DeviceValueEx(125) = 1 Then
      hs.SetDeviceString(124,"First", True)
      Mike____________________________________________________________ __________________
      HS3 Pro Edition 3.0.0.548, NUC i3

      HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

      Comment


        #4
        I believe your problem is that your IF statements have the then clause on the same line, so the IF statement is complete. The ELSEIF line the follows starts a new statement, and is not inside the first IF. You need to take the THEN clause and put it on a new line to keep the IF open for following statements.

        Wrong:

        if a then b
        else c
        endif

        Correct:

        if a then
        b
        else
        c
        end if


        tenholde
        tenholde

        Comment


          #5
          Originally posted by tenholde View Post
          I believe your problem is that your IF statements have the then clause on the same line, so the IF statement is complete. The ELSEIF line the follows starts a new statement, and is not inside the first IF. You need to take the THEN clause and put it on a new line to keep the IF open for following statements.
          Ed,
          Does that mean that all the Elseif lines are self contained? I was hoping that just breaking the first If line would be enough.

          The puzzle is that the script was working.
          Mike____________________________________________________________ __________________
          HS3 Pro Edition 3.0.0.548, NUC i3

          HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

          Comment


            #6
            Code:
            Sub Main(parm As Object)
                    If hs.DeviceValueEx(125) = 1 Then
                        hs.SetDeviceString(124, "First", True)
                    ElseIf hs.DeviceValueEx(125) = 2 Then
                        hs.SetDeviceString(124, "Second", True)
                    ElseIf hs.DeviceValueEx(125) = 3 Then
                        hs.SetDeviceString(124, "Third", True)
                    ElseIf hs.DeviceValueEx(125) = 4 Then
                        hs.SetDeviceString(124, "Forth", True)
                    ElseIf hs.DeviceValueEx(125) = 5 Then
                        hs.SetDeviceString(124, "Fifth", True)
                    ElseIf hs.DeviceValueEx(125) = 6 Then
                        hs.SetDeviceString(124, "Sixth", True)
                    ElseIf hs.DeviceValueEx(125) = 7 Then
                        hs.SetDeviceString(124, "Seventh", True)
                    ElseIf hs.DeviceValueEx(125) = 8 Then
                        hs.SetDeviceString(124, "Eighth", True)
                    ElseIf hs.DeviceValueEx(125) = 9 Then
                        hs.SetDeviceString(124, "Ninth", True)
                    ElseIf hs.DeviceValueEx(125) = 10 Then
                        hs.SetDeviceString(124, "Tenth", True)
                    ElseIf hs.DeviceValueEx(125) = 11 Then
                        hs.SetDeviceString(124, "Eleventh", True)
                    ElseIf hs.DeviceValueEx(125) = 12 Then
                        hs.SetDeviceString(124, "Twelth", True)
                    ElseIf hs.DeviceValueEx(125) = 13 Then
                        hs.SetDeviceString(124, "Thirt-teenth", True)
                    ElseIf hs.DeviceValueEx(125) = 14 Then
                        hs.SetDeviceString(124, "Four-teenth", True)
                    ElseIf hs.DeviceValueEx(125) = 15 Then
                        hs.SetDeviceString(124, "Fifth-teenth", True)
                    ElseIf hs.DeviceValueEx(125) = 16 Then
                        hs.SetDeviceString(124, "Six-teenth", True)
                    ElseIf hs.DeviceValueEx(125) = 17 Then
                        hs.SetDeviceString(124, "Seven-teenth", True)
                    ElseIf hs.DeviceValueEx(125) = 18 Then
                        hs.SetDeviceString(124, "Eight-teenth", True)
                    ElseIf hs.DeviceValueEx(125) = 19 Then
                        hs.SetDeviceString(124, "Nine-teenth", True)
                    ElseIf hs.DeviceValueEx(125) = 20 Then
                        hs.SetDeviceString(124, "Twentieth", True)
                    ElseIf hs.DeviceValueEx(125) = 21 Then
                        hs.SetDeviceString(124, "Twenty-first", True)
                    ElseIf hs.DeviceValueEx(125) = 22 Then
                        hs.SetDeviceString(124, "Twenty-second", True)
                    ElseIf hs.DeviceValueEx(125) = 23 Then
                        hs.SetDeviceString(124, "Twenty-third", True)
                    ElseIf hs.DeviceValueEx(125) = 24 Then
                        hs.SetDeviceString(124, "Twenty-fourth", True)
                    ElseIf hs.DeviceValueEx(125) = 25 Then
                        hs.SetDeviceString(124, "Twenty-fifth", True)
                    ElseIf hs.DeviceValueEx(125) = 26 Then
                        hs.SetDeviceString(124, "Twenty-sixth", True)
                    ElseIf hs.DeviceValueEx(125) = 27 Then
                        hs.SetDeviceString(124, "Twenty-seventh", True)
                    ElseIf hs.DeviceValueEx(125) = 28 Then
                        hs.SetDeviceString(124, "Twenty-eighth", True)
                    ElseIf hs.DeviceValueEx(125) = 29 Then
                        hs.SetDeviceString(124, "Twenty-ninth", True)
                    ElseIf hs.DeviceValueEx(125) = 30 Then
                        hs.SetDeviceString(124, "Thirtieth", True)
                    ElseIf hs.DeviceValueEx(125) = 31 Then
                        hs.SetDeviceString(124, "Thirty-first", True)
                    End If
                End Sub
            Also, your third SetDeviceString is mispelled.

            Finding and correcting this was trivial with: tenScripting3

            tenholde
            tenholde

            Comment


              #7
              Thank you everyone for replying. I have tried each suggestion, one at a time and I am still getting the errors. I just created events to set this device with the correct string that I wanted.

              I don't understand what happened because I was using this script for months with no problem. The errors started after I had a hard drive failure and had to put my HS project on another computer

              Comment


                #8
                Originally posted by sonypoolplr View Post
                I have tried each suggestion, one at a time and I am still getting the errors.

                I don't understand what happened because I was using this script for months with no problem. The errors started after I had a hard drive failure and had to put my HS project on another computer
                The first error is the one that has me puzzled.
                "Namespace or type specified in the Imports 'System.Core' doesn't contain any public member or cannot be found. "
                It's as if there is a component of vb.net that is missing. Is this a new computer? What version of the MS .NET Framework is installed?
                How did you install HS on the new computer?
                Mike____________________________________________________________ __________________
                HS3 Pro Edition 3.0.0.548, NUC i3

                HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

                Comment


                  #9
                  Namespace or type specified in the Imports 'System.Core' doesn't contain any public member or cannot be found


                  That is a catch all error message that appears often when otherr errors are present. Never seen a good explanation why. Eliminate the real errors, and that goes away.

                  tenholde
                  tenholde

                  Comment


                    #10
                    Originally posted by sonypoolplr View Post
                    Thank you everyone for replying. I have tried each suggestion, one at a time and I am still getting the errors. I just created events to set this device with the correct string that I wanted.

                    I don't understand what happened because I was using this script for months with no problem. The errors started after I had a hard drive failure and had to put my HS project on another computer
                    The code you posted could NOT have worked ever. It would never compile as you posted it, both because of the improper nesting of the IF and ELSEIF statements, but also because one of the hs function was mispelled:

                    Elseif hs.DeviceValueEx(125) = 3 Then hs.SetDeviceStringe(124,"Third", True)

                    Please look at the code I posted with proper nesting of conditional statements. I cannot test if it WORKS the way you want it to, but your code would never compile successfully. My correction to your code should. Cannot speak to if the logic is correct.

                    tenholde
                    tenholde

                    Comment

                    Working...
                    X