Hello,
I'd like to first start by saying that I am new to VB.net, an I am very grateful to Tenholder for writing tenScripting3 and recording such great intro videos so that novices such as myself can actually tinker, your contribution is appreciated and I am grateful!
I'm working on a script that will provide some missing functionality. I want to be able to fine tune the volume controls of a device by whatever increment I choose. When I try to run the script via HSTouch I receive the following error:
Running script ChangeVolume.vb :Exception has been thrown by the target of an invocation.->Does entry point Main 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 Scheduler.clsRunVBNetScript.ExecuteScript()
My script is as follows:
I have 4 audio zones, and my goal is to create 4 volume buttons per zone. 2 buttons for single volume increments/decrements, and 2 buttons for increments/decrements in steps of 5. If I use events, that would require 16 events. I would prefer to send parameters using HSTouch.
I wrote this script using tenScripting3 and tested it with the same, using parameters delimited by the pipe "|". After successfully importing the script into HS3, I tested again using a button and a few text elements, using "Homeseer: Run a Homeseer script with values from elements" by setting the text values and then calling the script with the values from the text elements as parameters. However the above error always shows up in the log when I press the button in HSTouch.
I suspect that the parameters are not being parsed correctly since I am not able to send a pipe "|" using HSTouch. My main issue is that I do not know what format the parameters are getting to the script, let alone how to parse them, since the Parms variable is an Object, not a string. I did try Parms(0), Parms(1), and Parms(2), but Visual Studio Express 2017 throws an error "Late bound resolution; runtime errors could occur."
Can anyone provide some insight on how I would be able to properly receive and parse the parameters being sent in HSTouch?
Thank you in advance!
I'd like to first start by saying that I am new to VB.net, an I am very grateful to Tenholder for writing tenScripting3 and recording such great intro videos so that novices such as myself can actually tinker, your contribution is appreciated and I am grateful!
I'm working on a script that will provide some missing functionality. I want to be able to fine tune the volume controls of a device by whatever increment I choose. When I try to run the script via HSTouch I receive the following error:
Running script ChangeVolume.vb :Exception has been thrown by the target of an invocation.->Does entry point Main 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 Scheduler.clsRunVBNetScript.ExecuteScript()
My script is as follows:
Code:
Public Class ChangeVolume Public Sub Main(ByVal Parms As Object) Dim ParmArray(10) As String ' Extract script parameters into ParmArray() ' Parms(0) Device ID ' Parms(1) String representing action type (i.e. inc or dec) ' Parms(2) Integer indicating incremental step (i.e. 1, 2, 5 etc) If Parms.ToString.Contains("|") Then ParmArray = Parms.ToString.Split(Convert.ToChar("|")) Else hs.WriteLog("Change Volume:", "No delimiter found, parsing skipped.") End If hs.WriteLog("Before IF", ParmArray(0) + " " + ParmArray(1) + " " + ParmArray(2)) '@DONOTEXPORT '' Get the current device volume level Dim theStatus As Integer = hs.DeviceValueEx(ParmArray(0)) hs.WriteLog("theStatus declared: ", ParmArray(0) + " " + ParmArray(1) + " " + ParmArray(2) + " " + theStatus.ToString) '@DONOTEXPORT '' Check requested command and incremental level and perform requested action If ParmArray(1).Contains("inc") Then theStatus += ParmArray(2) hs.CAPIControlHandler(hs.CAPIGetSingleControl(ParmArray(0), True, "Vol " & theStatus, False, False)) hs.WriteLog("Changed Volume +: ", ParmArray(0) + " " + ParmArray(1) + " " + ParmArray(2) + " " + theStatus.ToString) '@DONOTEXPORT Else theStatus -= ParmArray(2) hs.CAPIControlHandler(hs.CAPIGetSingleControl(ParmArray(0), True, "Vol " & theStatus, False, False)) hs.WriteLog("Changed Volume -: ", ParmArray(0) + " " + ParmArray(1) + " " + ParmArray(2) + " " + theStatus.ToString) '@DONOTEXPORT End If End Sub End Class
I wrote this script using tenScripting3 and tested it with the same, using parameters delimited by the pipe "|". After successfully importing the script into HS3, I tested again using a button and a few text elements, using "Homeseer: Run a Homeseer script with values from elements" by setting the text values and then calling the script with the values from the text elements as parameters. However the above error always shows up in the log when I press the button in HSTouch.
I suspect that the parameters are not being parsed correctly since I am not able to send a pipe "|" using HSTouch. My main issue is that I do not know what format the parameters are getting to the script, let alone how to parse them, since the Parms variable is an Object, not a string. I did try Parms(0), Parms(1), and Parms(2), but Visual Studio Express 2017 throws an error "Late bound resolution; runtime errors could occur."
Can anyone provide some insight on how I would be able to properly receive and parse the parameters being sent in HSTouch?
Thank you in advance!
Comment