Announcement

Collapse
No announcement yet.

first script

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

    first script

    Can anyone point out what's wrong with this script. I think I've got the syntax wrong somewhere. I'm getting an error expected then in line 3.

    sub main()

    if hs.devicevalue 3("]12") then
    hs.setdevicevalue "]12","0"
    end if

    end sub

    #2
    try this:

    if hs.devicevalue("]12") = 3 then
    hs.setdevicevalue "]12",0
    end if

    The Pod

    Comment


      #3
      That works fine. How would I make it respond across a range of values for ]12. would it need ELSE logic like

      sub main()

      if hs.devicevalue("]12") = 3 then
      hs.setdevicevalue "]12","0" else
      if hs.devicevalue("]12") = 2 then
      hs.setdevicevalue "]12","0"
      end if

      end sub

      That doesn't seem to work, so, is there a way of setting several values for the initial IF

      Comment


        #4
        You could try using a case statement instead of all the If's.

        John
        John

        Comment


          #5
          <BLOCKQUOTE class="ip-ubbcode-quote"><font size="-1">quote:</font><HR> You could try using a case statement instead of all the If's <HR></BLOCKQUOTE>

          Now you've lost me.

          Comment


            #6
            vworp,

            It would be like:

            sub main()

            Select Case CStr(hs.devicevalue("]12"))
            Case "3"
            hs.setdevicevalue "]12","0"
            Case "2"
            hs.setdevicevalue "]12","0"
            End Select

            End Sub

            Both cases seem to be doing the same thing, so you would probably put 3 and 2 together. Then maybe have a few others and possibly an else...

            Select Case CStr(hs.devicevalue("]12"))
            Case "3", "2"
            hs.setdevicevalue "]12","0"
            Case "1"
            hs.setdevicevalue "]12","1"
            Case Else
            all other values fall here...
            End Select

            Organize your conditions so the most likely choices to occur are towards the top.

            -Tom
            -Tom

            Visit Kernhome
            Kern Theater Gallery

            (User: guest / Pass: guest)

            Comment


              #7
              Cheers Tom. That works great.

              Max

              Comment

              Working...
              X