Announcement

Collapse
No announcement yet.

Passing variable to script

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Passing variable to script

    How do I pass a variable to a script in HSTouch?

    I need to pass the variable O13 to a script to operate a device - I have created an event to prove that the script works - but can't see how to pass the variable using HS Touch

    #2
    If I follow you...I take it you want to do this without a button press?

    Maybe you can utilise a virtual device? I'd set a virtual device from HSTouch with the immediate script command &hs.setdevicestring("X1", "O13", True) - you can embed this in a text element so it becomes [$SCRIPT=&hs.setdevicestring("X1", "O13", True)]

    Then in your script you would pull this with hs.devicestring("X1")...thats one of the slightly better ways of doing it I can think of, if you did this[$SCRIPT=&hs.runex("test.vb", "Main", "O13")] it would run the script every second which may have less than desirable results.

    If its not what your after tell me...it should be possible to do what your after.

    Comment


      #3
      I simply want to run a script at the press of a button - but passing a variable to the script..

      I was trying to use the "Run a HomeSeer script with values from elements(s)" when the button is pressed -but this option does not allow you to define the variable, but only allows you to take the variable from other elements - Am I tackling this from the wrong angle?

      Comment


        #4
        Ok...that should be quite easy, you are in the right area - select run a script with values from elements, then in the script box instead of using the drop down box that contains a list of scripts put in that box &hs.runex("Test.vb", "Main", "Variable") - don't select an existing script.

        That will then trigger that script and place 'Variable' (O13 in your case?) into the Main subroutine of test.vb

        Comment


          #5
          Many thanks mrhappy - not how I would have expected it to work, but I'm all up and running now .

          Comment

          Working...
          X