Announcement

Collapse
No announcement yet.

vb "imports" dll

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

    vb "imports" dll

    I developped a dll that include various fuctions: outilsbasic.dl

    when (using tenscripting) I put at the beginig of a vb file "Imports outilsbasic"
    it works (that is I can use MY functions without problem
    I copied my dll at the root of HS3, but when I try to use my vb script directly it can't compile (outilsbasic not found)

    What did I miss

    #2
    Check out the ScriptingReferences entry in settings.ini in the Config folder.

    Here is mine for allowing access to SQLite in scripts:
    Code:
    ScriptingReferences=system.data.sqlite;system.data.sqlite.dll
    https://forums.homeseer.com/showthread.php?t=172297

    Code:
    Note: This section is for VB.NET scripting only, for adding references to other DLL files, see the CSharp Scripting section.
    
    .NET uses "Namespaces" to refer to large libraries of code, which are not included in your VB.NET program or script unless you tell it that you wish to have it included.
    
    nBy default, VB.NET scripts executed by HomeSeer will have the System.dll referenced, which means that to use a namespace within that library, add the IMPORTS statement to the top of your VB.NET script like this:
           IMPORTS System.IO
           IMPORTS System.Net
    
     Note that all namespaces under System are not necessarily included in System.dll - some System namespaces are in additional dll files.
    
    If you wish to use other namespaces referenced in other libraries, you must first tell HomeSeer to include the library reference when it initializes the script engine.  To do this, add your reference to the INI entry "ScriptingReferences", which is under the [Settings] section in your \Config\Settings.INI file.
    
    You can add references by including the namespace, a semicolon, and the dll file name in this entry.  Multiple references can be added by separating them with a comma.  Here is an example that adds a reference to 2 namespaces:
    
    ScriptingReferences =
    
    System.Management;System.Management.dll,System.Drawing;System.Drawing.dll
     
    
    When broken down into individual parts:
    
    ScriptingReferences =
    
    System.Management;System.Management.dll,System.Drawing;System.Drawing.dll
      (Namespace1)    (DLL for Namespace1)  (Namespace2)  (DLL for Namespace2)

    tenholde
    tenholde

    Comment


      #3
      After reading these posts I got fired up and created a dll file that held my most commonly used functions and subs.

      When I tried to add it to the scripting reference section of the settings.ini file it would disappear after restarting HomeSeer. I must be misunderstanding something.

      As an aside, does one need to restart HomeSeer to have this all work?

      Thanks
      Don

      Comment


        #4
        Try stopping hs3, editing ini file, restart hs3
        tenholde

        Comment


          #5
          100 pct ok

          Originally posted by tenholde View Post
          Check out the ScriptingReferences entry in settings.ini in the Config folder.

          Here is mine for allowing access to SQLite in scripts:
          Code:
          ScriptingReferences=system.data.sqlite;system.data.sqlite.dll
          https://forums.homeseer.com/showthread.php?t=172297

          Code:
          Note: This section is for VB.NET scripting only, for adding references to other DLL files, see the CSharp cripting section.
          
          .NET uses "Namespaces" to refer to large libraries of code, which are not included in your VB.NET program or script unless you tell it that you wish to have it included.
          
          nBy default, VB.NET scripts executed by HomeSeer will have the System.dll referenced, which means that to use a namespace within that library, add the IMPORTS statement to the top of your VB.NET script like this:
                 IMPORTS System.IO
                 IMPORTS System.Net
          
           Note that all namespaces under System are not necessarily included in System.dll - some System namespaces are in additional dll files.
          
          If you wish to use other namespaces referenced in other libraries, you must first tell HomeSeer to include the library reference when it initializes the script engine.  To do this, add your reference to the INI entry "ScriptingReferences", which is under the [Settings] section in your \Config\Settings.INI file.
          
          You can add references by including the namespace, a semicolon, and the dll file name in this entry.  Multiple references can be added by separating them with a comma.  Here is an example that adds a reference to 2 namespaces:
          
          ScriptingReferences =
          
          System.Management;System.Management.dll,System.Drawing;System.Drawing.dll
           
          
          When broken down into individual parts:
          
          ScriptingReferences =
          
          System.Management;System.Management.dll,System.Drawing;System.Drawing.dll
            (Namespace1)    (DLL for Namespace1)  (Namespace2)  (DLL for Namespace2)

          tenholde
          What was a litle bit disturbing was the fact that "ScriptingReferences" entry didn't exist in seting.ini and that you have to add it.
          After modifying the ini file and restarting HS3 it worked as expected
          tks

          Comment


            #6
            Should have tried that.

            Thanks, Ed.

            Originally posted by tenholde View Post
            Try stopping hs3, editing ini file, restart hs3
            Don

            Comment


              #7
              OK, I must be missing something really basic here.

              I have included my dll in the scripting reference section on the settings.ini
              PHP Code:
              ..........  ,Helper.io;helper.dll 
              Created helper.dll
              PHP Code:
              Public Class helper

                  REM 
              '######################################################################
                  REM '
              ###                                                                ###
                  
              REM '###            Simplifies Logging                                  ###
                  REM '
              ###                                                                ###
                  
              REM '######################################################################

                  Public hs As HomeSeerAPI.IHSApplication

                  Public Sub LogIt(ByVal script As String, ByVal Message As String, ByVal Severity As Integer)

                      Dim ID As String = script

                      If Severity = 0 Then hs.WriteLogEx(ID, Message, "#80800")   '
              Black
                      
              If Severity 1 Then hs.WriteLogEx(IDMessage"#0000FF")  'Blue
                      If Severity = 2 Then hs.WriteLogEx(ID, Message, "#ADD8E6")  '
              Light Blue
                      
              If Severity 3 Then hs.WriteLogEx(IDMessage"#FF0000")  'Red
                      If Severity = 4 Then hs.WriteLogEx(ID, Message, "#FFA500")  '
              Orange

                  End Sub

              End 
              Class 
              Referenced it in a test script
              PHP Code:
              Imports Helper.io

               Sub Main
              (byVal args As String)
                  
              LogIt("test.vb""mymessage",2)
              End Sub 
              and get a 'LogIt' is not declared error.

              Any suggestions?
              Don

              Comment


                #8
                Bump
                Don

                Comment

                Working...
                X