Announcement

Collapse
No announcement yet.

hs.speak script variables

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

    hs.speak script variables


    Hi,

    I'm using a script and I'm trying to speak some variable values that are locally declared.
    All I want to do is insert the variable mid sentence, but I'm not sure of the correct formatting.
    I've searched high and low, but everything I've found references replacement / built-in variables.

    For example, this doesn't work, it probably won't anyway as it's parsed within quotes, but this is what I'm after.


    Code:
    Dim DeviceName As String = Washer
    
    
    hs.speak("The $$DeviceName is switched off")
    What is the proper formatting for script variables please?

    Thank you


    #2
    https://docs.homeseer.com/display/HS...ment+Variables

    Comment


      #3
      The way I've got this to work is to have a virtual device. I use the string of the virtual device to replace it into the speech script using $$DTA: (address).

      Comment


        #4
        Thanks, but I know about replacement variables, and while I can use some of them, there are none for some of my custom scripts. Using the format $$variable doesn't seem to work for non-replacement variables.

        Comment


          #5
          If you are declaring your variables within a script then this is not an HS function, but rather a VB script function. Hs.Speak is looking for a string of text, so you need to convert the number (I'm assuming) to a string. Any number of ways, a quick Google reveals:

          https://www.dotnetheaven.com/article...g-using-vb.net

          But your original example shows DeviceName.... so which is it, a locally defined script numerical variable or is it the value of a HS virtual device??

          Comment


            #6
            Originally posted by TC1 View Post
            If you are declaring your variables within a script then this is not an HS function, but rather a VB script function. Hs.Speak is looking for a string of text, so you need to convert the number (I'm assuming) to a string. Any number of ways, a quick Google reveals:

            https://www.dotnetheaven.com/article...g-using-vb.net

            But your original example shows DeviceName.... so which is it, a locally defined script numerical variable or is it the value of a HS virtual device??
            Hi and thanks,

            I've literally just found the answer, which was simple as expected I just didn't know - very new to scripting obviously.

            Answer:

            Code:
            hs.speak("The" & DeviceName & "is switched off")

            Comment


              #7
              Yep, that's called concatenation (using the ampersands to join pieces together within a string). Glad you got it sorted

              Comment

              Working...
              X