Announcement

Collapse
No announcement yet.

How to pass HS Touch label text into HS Script?

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

    How to pass HS Touch label text into HS Script?

    I am trying to pass the value of a label into a HS Script. I have tried two methods, and neither seem to work.

    I started by selecting my ActionType to be Run a HomeSeer script with values from elements. Then selected the VB script that I want to run from the drop down list. Typed in the function within the script (in this case Main), and finally, selected the label element from the drop down list of available elements. The receiving script looks as follows:

    Sub Main(ByVal parm As Object)
    Dim Val As String
    Dim splitString As String()

    splitString = Split(parms, char(7))
    Val = splitString(0)
    End Sub

    The value of Val is always blank.

    Then I tired a different approach. I tried passing the text value of the label element into a script on the command line using the following syntax:

    &hs.RunScriptEx "File.vb","Main",[$ELEMENT=screen_name->label_element]

    The receiving script in this case has been changed as follows as this should only be passing in a string:

    Sub Main(ByVal parm As String)
    Dim Val As String

    Val = parm
    End Sub

    When I try this method, I simply get a Script Error message appearing in the HS Log.

    I have no idea what I am doing wrong, but I am sure it is something really stupid. I am updating the text of a label element based on certain conditions, and I simply want to pass the current text string into a HS script, and have it act accordingly.

    Any assistance would be greatly appreciated!

    Cheers,

    George

    #2
    In the first script, could you add a hs.writelog "test","test" entry? Just to see if the script is running succesfull.

    I've been using a similar way to pass parameters to a script and it works. (it's slightly different).

    Code:
    Sub Main(ByVal varParameters as Object)
        Dim varHours() as String
        Dim varMinutes() as String
    
        varHours = Split(varParameters(0), Chr(7))
        varMinutes = Split(varParameters(1), Chr(7))
    
        hs.writelog("DJ_Test","<b>Hours=</b>" & varHours(0))
        hs.writelog("DJ_Test","<b>Minutes=</b>" & varMinutes(0))    
    End Sub
    Cheers
    DJ

    Comment

    Working...
    X