Announcement

Collapse
No announcement yet.

Can someone help with Syntax

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

    Can someone help with Syntax

    Hi Guys,

    I am sure you will all look at this and laugh, but can someone please give me the correct syntax for the below script. I am struggling with it. Also does anyone know a good reference that I can use to work these things out on my own. I am new to the scripting side of things and could really use a guide or crash class.

    Sub Main

    if hs.IsOn(Z1) then
    hs.SetDeviceValue "Z1",off
    HS.TriggerEvent(blah blah)
    else
    hs.SetDeviceVaule "z1",ON
    HS.Triggerevent(blu blu)
    end if

    End Sub

    thanks
    MB

    #2
    Good reference?

    It is worth buying the O'Reilly Pocket Reference for vb.net.

    The one I have is ISBN 0-596-00428-1

    You do need to remember that HS only add the functions to the language, and the functions are described (somewhat) in the HS Help files.

    I would certainly go for the pocket reference, and bet its bigger brother if you really get into it.

    Hope that is of some help.

    D
    ---------------------------------------------------http://weather.penicuik.org

    Comment


      #3
      Code:
      Sub Main
      
      if hs.IsOn(Z1) then
      hs.SetDeviceValue "Z1",off
      HS.TriggerEvent "blah blah"
      else
      hs.SetDeviceValue "z1",ON
      HS.Triggerevent "blu blu"
      end if
      
      End Sub
      Try that. Other that the typo I believe you want quotes. You use parenthesis in VBSCRIPT when you want to RETURN a value like in your IsOn statements.


      ~Bill

      Comment


        #4
        Also to help us help you post the error in the HS2 log.

        If you are using VBSCRIPT it narrows it down pretty well.

        In .NET scripting it the error logs get really crazy, that's why I stick with VBSCRIPT for now.


        ~Bill

        Comment


          #5
          Error messages for VB.NET scripting can actually be more powerful than VBScript. Google VB.NET error handling (Try/Catch/End Try). VB.NET also supports the "undocumented" ERL function where you can specify the line number of where the error occurred. Unless you have an editor with built-in functionality, it is tedious to add line numbers.
          Jim Doolittle

          My Twitter
          My Hardware & Software

          Comment


            #6
            Well Latin is a superior language to English but it still makes me glaze over...


            ~Bill

            Comment


              #7
              I'm with you brother Bill. But then, I took Latin 1 for five semesters...

              Originally posted by Bill Brower View Post
              Well Latin is a superior language to English but it still makes me glaze over...
              Don

              Comment


                #8
                Code:
                Sub Main
                
                if hs.IsOn(Z1) then
                 hs.SetDeviceValue "Z1","off"
                 HS.TriggerEvent "blah blah"
                else
                 hs.SetDeviceValue "z1","ON"
                 HS.Triggerevent "blu blu"
                end if
                
                End Sub
                I'm assuming that you want the text 'off' and 'ON' to be assigned to the device value, so unless you've defined variables (and values) for 'off' and 'ON', you need to place these in quotes as well.
                Best regards,
                -Mark-

                If you're not out on the edge, you're taking up too much room!
                Interested in 3D maps? Check out my company site: Solid Terrain Modeling

                Comment


                  #9
                  We really need to know what you are trying to do because I don't think SetDeviceValue is what you want. SetDeviceValue now that I look is supposed to a number 0 - 100 - see the bottom of this post.

                  You may be wanting SetDeviceStatus or SetDeviceString.


                  SetDeviceValue

                  Purpose

                  This function sets a value that is associated with this device. Values are used to hold the dim level of a device. You can also use them as user variables in your scripts. Note that HomeSeer will overwrite this value if a command was received for this device. If you are going to use this as storage for your own information, pick a device that does not exist in your home. You can also use virtual devices (devices in the range "q -> z" or unit codes between 17 and 64).
                  Parameters

                  Parameter: device
                  Type: string
                  Description: This is the device code, such as "A1".
                  Parameter: value
                  Type: long
                  Description: This is a numeric value, such as "50".
                  Returns

                  None.
                  Example

                  sub main()
                  ' set the dim value of device B2 to 60%
                  hs.SetDeviceValue "B2",60
                  end sub


                  ~Bill

                  Comment


                    #10
                    http://homeseer.com/support/homeseer...st_devices.htm


                    ~Bill

                    Comment


                      #11
                      so here is my SIMPLE working script to toggle the power on or off for my theater based on he current value of the "theater Power" virtual device (Z1). I am using this as a script behind a button in HST to turn the power on or off. I didnt want a button for each command and therefor needed this flip flop action.

                      Sub Main()
                      if hs.DeviceValue("Z1") = "0" then 'The Power is Off
                      hs.triggerevent("theater equipment on") 'Turn it on
                      else
                      hs.triggerevent("theater equipment off") 'Turn it off
                      end if
                      End Sub
                      within each event is a command to flip flop the current status of z1, so if its on it turn off or vice versa.

                      I am sure you guys look at how easy this is and laugh, but it was a major accomplishment for me, and my wife and I are going celebrating tonight..

                      Comment

                      Working...
                      X