Announcement

Collapse
No announcement yet.

Sub Class

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

    Sub Class

    Hello people,

    Here's my simplified code and errors. "TestParameters" is the vilian but why. This and all my simplified code works within tenScripting but place it into scripts under HS3 and and trigger it (Test2.Main) via an event and it fails.

    Code:
    Public Class Test2
    
        Public Sub Main(Parms As Object)
    
            Dim p As TestParameters = Nothing
    
        End Sub
    
    End Class
    
    Public Class TestParameters
    
        Public _paramINT As Integer = 0
    
        Public Sub Here()
    
        End Sub
    
        Public Property ParamINT As Integer
            Get
                Return _paramINT
            End Get
            Set(value As Integer)
                _paramINT = value
            End Set
        End Property
    
    End Class
    Dec-04 9:20:58 AM Error Compiling script C:\Program Files\HomeSeer HS3\scripts\Test2.vb: Type 'TestParameters' is not defined.
    Dec-04 9:20:58 AM Error Compiling script C:\Program Files\HomeSeer HS3\scripts\Test2.vb: Namespace or type specified in the Imports 'System.Core' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
    Dec-04 9:20:57 AM Event Running script in background: C:/Program Files/HomeSeer HS3/scripts/Test2.vb("Main")
    Dec-04 9:20:57 AM Event Event Trigger "Test Thread"
    Dec-04 9:20:57 AM Event Event Test Thread triggered by the event page 'Run' button.

    J

    #2
    Is the code you posted exactly as it appears in the script folder file?

    If so, the Class/End Class statements around the Sub Main shouldn't be there.

    When testing under tenScripting, there should be a set of Class/End Class
    around the entire set of code.

    Did you use the Export function to move the script from tenScripting to the script folder, or did you do so manually?

    tenholde
    tenholde

    Comment


      #3
      Originally posted by tenholde View Post
      Is the code you posted exactly as it appears in the script folder file?

      If so, the Class/End Class statements around the Sub Main shouldn't be there.

      When testing under tenScripting, there should be a set of Class/End Class
      around the entire set of code.

      Did you use the Export function to move the script from tenScripting to the script folder, or did you do so manually?

      tenholde
      No, There are two scripts that where generated in the Scripts folder (Test2 and TestParameters), both without the Class/End Class. I have tried to instantiate the class TestParameters and change it to a structure but something is not playing nice.

      By the way, your scripting tool rocks!

      J

      Comment


        #4
        In order to instantiate an object within an HS3 script, it must either be defined within that same script, or be compiled into a DLL file, and that DLL file must be loaded by HS3 when it starts up (settings.ini parameter: ScriptingReference)

        You cannot define a class in one HS3 script and use it in another HS3 script. Only one is compiled and loaded into memory at the same time. You should define the class and use it within a single script. In tenscripting, your structure would look something like:

        Class myScriptName
        use myClass

        Class myClass
        define myClass
        End Class
        End Class


        The reason you were able to make it work within tenScripting is that when you run the tenScripting project, Visual Studio compiles ALL of the .vb files in the project and loads them into memory.

        tenholde
        tenholde

        Comment


          #5
          Originally posted by tenholde View Post
          In order to instantiate an object within an HS3 script, it must either be defined within that same script, or be compiled into a DLL file, and that DLL file must be loaded by HS3 when it starts up (settings.ini parameter: ScriptingReference)

          You cannot define a class in one HS3 script and use it in another HS3 script. Only one is compiled and loaded into memory at the same time. You should define the class and use it within a single script. In tenscripting, your structure would look something like:

          Class myScriptName
          use myClass

          Class myClass
          define myClass
          End Class
          End Class


          The reason you were able to make it work within tenScripting is that when you run the tenScripting project, Visual Studio compiles ALL of the .vb files in the project and loads them into memory.

          tenholde
          Ahhh,

          Makes sense. I think I have a solution using RunScriptFunc().
          J

          Thanks Again!

          Comment

          Working...
          X