Announcement

Collapse
No announcement yet.

Error running called script via &hs.DeviceScriptButton_AddButton

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

    Error running called script via &hs.DeviceScriptButton_AddButton

    &hs.DeviceScriptButton_AddButton. The button presses call a separate (for now) corresponding .net script whose only purpose is to trigger an existing HS3 event.

    Code:
    
     &hs.DeviceScriptButton_AddButton("126", "Off", 607001, "yamahaavroffbutton.vb",  "ZMain", "Yamaha AVR Off", 1, 1, 1)
     &hs.DeviceScriptButton_AddButton("126", "On", 607002, "yamahaavronbutton.vb",  "ZMain", "Yamaha AVR On", 1, 2, 1)
     


    The buttons populate and successfully call the scripts located in the /scripts folder when pressed.

    Code:
     
     Imports System.IO
     Imports System.Text
     Imports System.Net
      
     Public Sub ZMain(Parms As Object)
     Dim ParmArray() As String
     ParmArray = Parms.ToString.Split("|")
     Dim hs3devid As String = (ParmArray(0))
     Dim hs3action As String = (ParmArray(1))
     hs.TriggerEvent("Yamaha AVR Off")
      
     End Sub
    However, the script fails with the following log message:

    Running script yamahaavroffbutton.vb :Exception has been thrown by the target of an invocation.->Does entry point ZMain exist in script? at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Obj ect obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at A.c17b105f989efe61e5979e67bec1ef734.cffd66cb0782c50126727e3f a75582d7a()



    Any suggestions you can offer are appreciated!


    #2
    The problem is Objec vs String

    The problem is Objec vs String, convert the object parsed by the button to an string:

    Sub xxxxx(parameters as object)

    Dim dvRef As Integer = parameters(0) 'Integer - The device reference ID.
    Dim Value As String = parameters(1)


    Hope this helps

    Comment


      #3
      Dropping the string split & those changes did it - thanks very much!

      Comment

      Working...
      X