Announcement

Collapse
No announcement yet.

Reference to a non-shared member requires an object reference

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

    Reference to a non-shared member requires an object reference

    I have recently upgraded to HS4 for Windows and my scripts that used to work in HS3 are now giving an "Reference to a non-shared member requires an object reference" error in the Homeseer log when compiling.

    I used this script for incremental dim/brighten of z-wave dimmers in HS3 which I found here Source: https://forums.homeseer.com/forum/li...-to-install-it. I have tried fruitlessly to debug it on HS4. There are very few references to this error on the internet. I have used tenScripting for HS4 to debug it and have ended up modifying it to this which tenscript says has no errors.

    VB Script

    Class dimChange
    Sub Main(ByVal inputparmaters As String)
    ' parameter "1234,10" device Reference ID followed by percentage change "-" for down
    Dim myInputParmaters
    Dim myPos
    Dim myStringSize As New Integer
    Dim myTargetDevice As New Double
    Dim myTargetDimAmount As New Double
    Dim myDeviceValue As New Double
    Dim debugMode As New Boolean
    debugMode = True
    myPos = InStr(CStr(myInputParmaters), ",")
    myStringSize = Len(myInputParmaters)
    myTargetDevice = Left(myInputParmaters, myPos - 1)
    myTargetDimAmount = Right(myInputParmaters, myStringSize - myPos)
    myDeviceValue = hs4.DeviceValue(myTargetDevice) + myTargetDimAmount
    hs4.WriteLog("Dim Script", CStr(myDeviceValue))
    Dim p = hs4.CAPIControlHandler(hs4.CAPIGetSingleControl(myTargetDevi ce, False, CStr(myDeviceValue), False, True))
    End Sub
    End Class

    #2
    not a scripting expert, but is this a global reference

    hs4.WriteLog

    or is it hs.WriteLog

    Is this script a .txt file or .vb?



    Comment


      #3
      HS3 scripts should work just as well in HS4 so changing hs.xxx to hs4.xxx is not necessary.

      I can see that you are trying to do string manipulation on a string that has not been defined i.e.

      Code:
      Dim myInputParmaters
      
      myPos = InStr(CStr(myInputParmaters), ",")
      myStringSize = Len(myInputParmaters)
      myTargetDevice = Left(myInputParmaters, myPos - 1)
      Assuming you want to use the Script parameter string, replacing the Dim line with the following should work:

      Code:
      Dim myInputParmaters As String = inputparmaters

      Jon

      Comment


        #4
        Thanks, I eventually figured it out. Turns out my HS4 install was corrupt. A reinstall and the scripts started working.

        Comment

        Working...
        X