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:
    [FONT=Verdana]
     [COLOR=red][FONT=Verdana][COLOR=black]&hs.DeviceScriptButton_AddButton("126", "Off", 607001, "yamahaavroffbutton.vb",  "ZMain", "Yamaha AVR Off", 1, 1, 1)[/COLOR]
     [COLOR=red][FONT=Verdana][COLOR=black]&hs.DeviceScriptButton_AddButton("126", "On", 607002, "yamahaavronbutton.vb",  "ZMain", "Yamaha AVR On", 1, 2, 1)[/COLOR][/COLOR]
     [/FONT]
    [/FONT][/COLOR]

    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!

    [/FONT]

    #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


        #4
        I too am stuck.

        Cant parse it correctly. what is the proper signature of the Button() method and how to parse parms coming into it.

        hs.DeviceScriptButton_AddButton(dvRef, Name, 1234, "valueChanged.vb", "Main", "Up", 1, 1, 1)


        Sub Button(Parms As Object)

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

        hs.WriteLog("Test", dvRef.ToString())

        End Sub

        get error:

        Running script valueChanged.vb :Object of type 'System.Object[]' cannot be converted to type 'System.String'.->Does entry point Main exist in script? at System.RuntimeType.CheckValue (System.Object value, System.Reflection.Binder binder, System.Globalization.CultureInfo culture, System.Reflection.BindingFlags invokeAttr) [0x00071] in :0 at System.Reflection.RuntimeMethodInfo.ConvertValues (System.Reflection.Binder binder, System.Object[] args, System.Reflection.ParameterInfo[] pinfo, System.Globalization.CultureInfo culture, System.Reflection.BindingFlags invokeAttr) [0x00069] in :0 at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00040] in :0 at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in :0 at Scheduler.clsRunVBNetScript.ExecuteScript () [0x003b2] in :0



        Comment

        Working...
        X