Announcement

Collapse
No announcement yet.

Using parameters by scripts

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

    Using parameters by scripts

    I'm quite new in Homeseer and quite new in scripting.
    I created a simple vb-script to set one of my devices to a certain value, this works fine:

    Code:
     Sub Main()
        Dim DevRef
        Dim DevValue
        DevRef = hs.GetDeviceRefByName("VirtualDevice")
        DevValue = 10
        if hs.ison(DevRef) then
            hs.Speak "The device is set to " & DevValue
            hs.CAPIControlHandler(hs.CAPIGetSingleControl(hs.GetDeviceRefByName("DMXRood"),false,"100",false,true))
        end if
     End Sub
    I want to use the 'Parameters' field to specify the value but I can't get this working.




    Can anyone help me?

    Thanx in advance.

    #2
    Following is code that uses the parameters from the event:

    Code:
    Public Sub Main(ByVal Parms As Object)
            ''
            '' Simple Sample Using Multiple Parms
            ''
            '''' Specify two parms, separated by a vertical bar character ("|")
            ''''
            ''''   The 1st parm is the text spoken
            ''''   The 2nd parm is the text written to the HS log
            ''
            Dim ParmArray() As String
    
            ParmArray = Parms.ToString.Split("|")                       ' split parameter string into parm array
            hs.Speak(ParmArray(0))                                      ' speak 1st parm
            hs.WriteLog("SpeakAndLogMultipleParms", ParmArray(1))       ' log 2nd parm
        End Sub
    In the event definition, set the Sub/Function name to: Main

    In the parameters field, separate the two parameters with a vertical bar

    tenholde
    tenholde

    Comment


      #3
      Thank you very much tenholde, it's working fine now...

      It didn't work directly, but I think the file format was the problem. The file had a .vbs extention... after saving it as .vb everything worked fine.

      In the documentation of HS3 I can read that both .vb and .vbs are supported, but what is exactly the difference between both formats?

      Comment


        #4
        .vb are .net scripts,

        .vbs are vb scripting files.



        Stick with .net.




        tenholde
        tenholde

        Comment


          #5
          That's clear, thank you for helping me!

          Comment


            #6
            And thank you from me

            Thanks so much.
            The Parms object really should be in the online documents for Scripting but I could not find it.

            Comment

            Working...
            X