Announcement

Collapse
No announcement yet.

Baffled by a One-Liner

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

    Baffled by a One-Liner

    I am getting the following error in HS4 when I try to run this one line script, either in an event action or in the Tools/Script Command page:
    Running script(2) & If hs.GetListenStatus ("Audrey11efault") Then hs.SetDeviceValueByRef (1285, 100, True) Else hs.SetDeviceValueByRef (1285, 0, True), init error: Syntax error

    Oddly this one-liner is very similar to the example of a one-liner given in the help file. I have tried with parentheses and without, I've tried appending with nhs, I've tried SetDeviceValue and SetDeviceValueByRef, but I always get a syntax error. If I run the component pieces of the statement, they execute fine alone or in another If statement, but for some reason I cannot seem to get this combination to run.

    I'm simply trying to toggle a virtual device to indicate whether voice recognition is listening or not.

    I appreciate any advice.
    Mark

    #2
    Try this:

    Code:
     &nhs.version : If hs.GetListenStatus ("Audrey11:default") Then hs.SetDeviceValueByRef (1285, 100, True) Else hs.SetDeviceValueByRef (1285, 0, True)
    Jon

    Comment


      #3
      Originally posted by jon00 View Post
      Try this:

      Code:
       &nhs.version : If hs.GetListenStatus ("Audrey11:default") Then hs.SetDeviceValueByRef (1285, 100, True) Else hs.SetDeviceValueByRef (1285, 0, True)
      Thank you so much Jon00 - that works. nhs.version is new to me. Are there particular circumstances where this is required? The documentation for HS scripting is somewhere between awful and non-existent.
      Mark

      Comment


        #4
        It just needs any Homeseer command (could be anything but hs.version is a good one) starting with &nhs. to compile the temporary script correctly.

        Basically, immediate scripts are buggy in HS4. There are even differences required between Windows or Linux!
        Jon

        Comment


          #5
          Originally posted by jon00 View Post
          It just needs any Homeseer command (could be anything but hs.version is a good one) starting with &nhs. to compile the temporary script correctly.

          Basically, immediate scripts are buggy in HS4. There are even differences required between Windows or Linux!
          I Jon,

          I would be curious to know your your opinion on that, about the buggy immediate script in hs4 .

          Comment


            #6
            Originally posted by pistacheL0 View Post
            I Jon,

            I would be curious to know your your opinion on that, about the buggy immediate script in hs4 .
            I have no real opinion on this. All software has bugs. In this particular case it has been the result of backwards support from Homeseer 2 days when everything was using VBScript. As you know, this had to change when Linux/Mono became part of the equation and the slight formatting differences between Mono/Windows VB.NET support.

            The current issue is that you have to start an immediate script command with &nhs. for HS to create a temporary VB.NET script. As per the OP, that may not be the requirement. I'm sure that could be improved.....

            As there are methods to get around these issues, any potential fixes will never be high priority IMO.


            Jon

            Comment


              #7
              Thank you Jon!

              Comment

              Working...
              X