Announcement

Collapse
No announcement yet.

Control devices with scripting

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

    Control devices with scripting

    I'm using Ed's tenScriptAid to write a script to control multiple devices. I have virtual devices to handle security stuff and I need to change them at Sleep and Wake.
    Ed uses a boolean in his examples like this.
    PHP Code:
    Dim rc As Boolean
    rc 
    hs4.SendControlForFeatureByValue(280
    Probably a stupid question by what is the best way to deal with the boolean, declare it and then force it to 'nothing' after the hs4.SendControlForFeatureByValue statement or
    just skip the boolean declaration and use the hs4.SendControlForFeatureByValue command. I'm trying to change four or five different devices and would like to not have to declare
    four or five seperate booleans.

    Thanks
    Don

    #2
    rc only contains the return code of the function (worked or it didn't work). As the call is a function call and not a subroutine call, functions always return a return code.

    You can reuse rc as much as you'd like.

    Comment


      #3
      Thanks
      Don

      Comment


        #4
        Originally posted by donstephens View Post
        I'm using Ed's tenScriptAid to write a script to control multiple devices. I have virtual devices to handle security stuff and I need to change them at Sleep and Wake.
        Ed uses a boolean in his examples like this.
        PHP Code:
        Dim rc As Boolean
        rc 
        hs4.SendControlForFeatureByValue(280
        Probably a stupid question by what is the best way to deal with the boolean, declare it and then force it to 'nothing' after the hs4.SendControlForFeatureByValue statement or
        just skip the boolean declaration and use the hs4.SendControlForFeatureByValue command. I'm trying to change four or five different devices and would like to not have to declare
        four or five seperate booleans.

        Thanks
        Might want to actually check that the call was successful. Something like

        Code:
        If Not hs4.SendControlForFeatureByValue(28, 0) then
           hs.Writelog.........call failed,etc.
           Endif
        Don't even need to declare a variable for the result
        tenholde

        Comment


          #5
          Yeah, great idea. Worked great. Thanks.
          Don

          Comment


            #6
            From my experience I always prefer local declaration for two reasons: if rc is declared somewhere else, later looking at your code you will be wondering what's rc? And if later you decide to delete the beginning of your code (which includes the declaration, or you want to rename rc) - suddenly you get the "undefined variables" errors all over your code.
            You can simply define inline i.e.
            Code:
            Dim rc = hs4.SendControlForFeatureByValue(28, 0)
            But I agree with tenholde (post #4) - it's even better option

            Comment

            Working...
            X