Announcement

Collapse
No announcement yet.

Script error , need advice

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

    Script error , need advice

    Hi all

    im building a script and this is not working for me , i get this error

    This is the error:

    It can not be made to the local variable Value before it is declared.
    It can not be made to the local variable Value before it is declared.
    It can not be made to the local variable Ref before it is declared.
    It can not be made to the local variable Ref before it is declared.


    Ref is already declared and also Value like this :
    Dim Ref
    Dim Value

    THis is the code i need to insert , when i delete that the script works normal...

    Code:
    Ref = hs.GetDeviceRef("Server TEST ID")
    hs.SetDeviceValueByRef(Ref, 1 , True)
    Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
    Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




    HS3Pro 4.1.14.0 on windows 10 enterprise X64 on hp quadcore laptop 8 GB.

    #2
    Originally posted by Malosa View Post
    Hi all

    im building a script and this is not working for me , i get this error

    This is the error:

    It can not be made to the local variable Value before it is declared.
    It can not be made to the local variable Value before it is declared.
    It can not be made to the local variable Ref before it is declared.
    It can not be made to the local variable Ref before it is declared.


    Ref is already declared and also Value like this :
    Dim Ref
    Dim Value

    THis is the code i need to insert , when i delete that the script works normal...

    Code:
    Ref = hs.GetDeviceRef("Server TEST ID")
    hs.SetDeviceValueByRef(Ref, 1 , True)
    should ref be...
    Ref = hs.GetDeviceRefByName("Server TEST ID")
    if you want to find the ref no based on a device name?

    Comment


      #3
      yes i need to set the device to a number


      but i try it but still doesnt work , still that error

      do i need it to declare it different ? like:

      dim Ref as ?
      Dim value as ?


      the script is inside this :


      Sub Main(parm as object)


      exit sub
      Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
      Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




      HS3Pro 4.1.14.0 on windows 10 enterprise X64 on hp quadcore laptop 8 GB.

      Comment


        #4
        Go To TOOLS --> CONTROL PANEL
        and run the following immediate script:

        &hs.writelog("Info",hs.GetDeviceRefbyName("Server TEST ID"))

        then check your log..does it give a number in the log?

        Other thing to try is to declare it as the correct type and not as object....
        Dim ref as Integer

        Comment


          #5
          With immediate it works normal ,

          but in my big script i need to insert it .

          i did this in my script:

          Dim Ref as Integer
          Ref = hs.GetDeviceRefByName("Server TEST ID")
          hs.SetDeviceValueByRef(Ref, 8 , True)



          This is what i get when i dim as Integer


          The ref variable hides a variable in an enclosing block


          The namespace or type in the Imports statement System.Core does not contain any public member or can not be found . Make sure the namespace or the type is defined and contains at least one public member . Make sure the imported element name does not use any aliases.



          Originally posted by russr999 View Post
          Go To TOOLS --> CONTROL PANEL
          and run the following immediate script:

          &hs.writelog("Info",hs.GetDeviceRefbyName("Server TEST ID"))

          then check your log..does it give a number in the log?

          Other thing to try is to declare it as the correct type and not as object....
          Dim ref as
          Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
          Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




          HS3Pro 4.1.14.0 on windows 10 enterprise X64 on hp quadcore laptop 8 GB.

          Comment


            #6
            "The ref variable hides a variable in an enclosing block"


            normally means you have "dim ref" used somewhere else in the same method/function
            (ie you are declaring the same variable twice)

            Can you check?
            If its still not working..do you want to share the script and I can have a quick look?

            Comment


              #7
              yes its declared somewhere else ,

              but if i delete that dim line , i get this error


              It can not be made to the local variable Ref before it is declared.




              Originally posted by russr999 View Post
              "The ref variable hides a variable in an enclosing block"


              normally means you have "dim ref" used somewhere else in the same method/function
              (ie you are declaring the same variable twice)

              Can you check?
              If its still not working..do you want to share the script and I can have a quick look?
              Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
              Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




              HS3Pro 4.1.14.0 on windows 10 enterprise X64 on hp quadcore laptop 8 GB.

              Comment


                #8
                another option is to skip the declare and just use it straight...

                hs.SetDeviceValueByRef(hs.GetDeviceRefbyName("Server TEST ID"), 1 , True)

                the only problem with this is that it gets harder to read the code for troubleshooting afterwards!

                Comment


                  #9
                  ok no error but no change in the value really weird


                  Originally posted by russr999 View Post
                  another option is to skip the declare and just use it straight...

                  hs.SetDeviceValueByRef(hs.GetDeviceRefbyName("Server TEST ID"), 1 , True)

                  the only problem with this is that it gets harder to read the code for troubleshooting afterwards!
                  Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
                  Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




                  HS3Pro 4.1.14.0 on windows 10 enterprise X64 on hp quadcore laptop 8 GB.

                  Comment


                    #10
                    Did the value change when you ran it as an immediate command?
                    Where are you checking the value? In the ADVANCED tab of the device?

                    Comment


                      #11
                      it works perfect now , i will release this script in 1 hour , i hope you like it , and you still can edit it .

                      regards and many thanks
                      Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
                      Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




                      HS3Pro 4.1.14.0 on windows 10 enterprise X64 on hp quadcore laptop 8 GB.

                      Comment


                        #12
                        I wonder if 'Ref' has special meaning in the hs object. What happens if you use a different name for the variable, like intRef?
                        Mike____________________________________________________________ __________________
                        HS3 Pro Edition 3.0.0.548, NUC i3

                        HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

                        Comment


                          #13
                          if i do that it still doesnt work.

                          but i updated russr999 his script ,
                          check here

                          http://board.homeseer.com/showpost.p...3&postcount=19


                          Originally posted by Uncle Michael View Post
                          I wonder if 'Ref' has special meaning in the hs object. What happens if you use a different name for the variable, like intRef?
                          Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
                          Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




                          HS3Pro 4.1.14.0 on windows 10 enterprise X64 on hp quadcore laptop 8 GB.

                          Comment

                          Working...
                          X