Announcement

Collapse
No announcement yet.

RunScriptFunc with mixed type params?

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

    RunScriptFunc with mixed type params?

    Code:
    Public Sub UpdateDevice(ByVal iDeviceID As Integer, ByVal dblDeviceValue As Double, ByVal sDeviceString As String)
    
            hs.SetDeviceValueByRef(iDeviceID, dblDeviceValue, True)
            hs.SetDeviceString(iDeviceID, sDeviceString, True)
            hs.SetDeviceLastChange(iDeviceID, Now)
    
    End Sub
    Code:
    scr As String, func As String, param As Object, Wait As Boolean, SingleInstance As Boolean
    • Do I create an array of strings (which means converting before invoking and then again in the sub) and pass it that?
    • Do I create an object containing mixed types?
    • Do I modify the definition of the sub to accept maybe an object and then parse it?

    #2
    HS scripts can only take a single argument, an array of strings.

    Every one of your utility scripts should be defined that way.




    There is another approach that you might want to use sometimes. Let say you have five or so scripts that all deal with controlling the music in your den. Each one of these scripts make use of 3 of the same functions that you would like to not duplicate in each script.

    Define a single script with 5 entry points and 3 functions. Each of the 5 script entry points (declared public, HS calling sequence) can reference one or more of the 3 functions (defined private, and with any calling sequence) contained in the same script definition.


    You could take this to the ultimate and define ALL of your scripts as separate entry points within a single script file, and include all of your utility functions within it. These utility functions can have any calling sequence you want.

    This is pretty easy to manage if you are using tenScripting.

    tenholde
    tenholde

    Comment


      #3
      Tenholde,

      have been using TenScripting for years and love it, thanks!

      I have done the following and it works, so I think I am OK.

      1. Created a test utility class as follows:

      Code:
      Class SBTestUtility
          Public Sub Main(ByVal Parms As Object)
              Dim dvRef As Integer = 0
              Dim dvValue As Double = 0
              Dim dvStatus As String = ""
      
              dvRef = Parms(0)
              dvValue = Parms(1)
              dvStatus = Parms(2)
      
              hs.SetDeviceValueByRef(dvRef, dvValue, True)
              hs.SetDeviceString(dvRef, dvStatus, True)
              hs.SetDeviceLastChange(dvRef, Now)
      
          End Sub
      End Class
      2. Then a test class to invoke this, as follows:

      Code:
      Class SBTestInvoke
          Public Sub Main(ByVal Parms As Object)
      
              Dim dvRef As Integer = 641
              Dim dvValue As Double = 35.4
              Dim dvStatus As String = "Hello this is a test"
      
              hs.RunScriptFunc("SBTestUtility.vb", "Main", {dvRef, dvValue, dvStatus}, True, True)
      
          End Sub
      End Class
      All I need to do now is move the code in Main of the TestUtility class to a different Sub and check all works as expected. Once that is OK I will add other Subs for the common functions I need.

      Do you see anything wrong with the code posted?

      Thanks!!!

      Comment


        #4
        looks good
        tenholde

        Comment

        Working...
        X