Announcement

Collapse
No announcement yet.

Using Visual Basic 2005 Express Edition for scripting

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

    #31
    Originally posted by Per4merKC View Post
    Tenholde,

    Your interface is amazing! I have been more productive in my programming over the last few days because of your product!

    I've gone back and done clean-up work on most of my old scripts, converting them to .vb, and even tuned some frustrating things about other peoples' scripts that I was dreading because of the inability to step through code.

    BRAVO!!!
    A new version is available with real documentation now at:

    http://www.tenholder.net/tenWare2/tenScripting
    tenholde

    Comment


      #32
      Please forgive me, but I am just not getting it. I read the documentation on the tenholde site, and was able to get the development environment up and running. It connects to my Homeseer computer and logs in correctly.

      Then, I did a file open and loaded one of my scripts. It loaded in the development area, not the tenholde project page. When I try to make it run by clicking on the green run icon, it runs the tenholde project page, and not my code that I just loaded.

      Can anyone tell me what I'm doing wrong?
      A computer's attention span is as long
      as it's powercord.

      Comment


        #33
        The green run icon runs the solution, which is tenscripting. You will need to add your own .vb code to the solution. When it comes time to run, just use the tenscripting interface to run your code, using the large button in the middle.
        HS4Pro on a Raspberry Pi4
        54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
        Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

        HSTouch Clients: 1 Android

        Comment


          #34
          sdanks,

          You need to put your script into tenscripting in a special way. You "Add New Item" of type "Class" to the tenscripting project and name the class whatever you want your script to be called. Your script is then a class within the tenscripting project that you can add public subroutines and functions to that will appear within your script. When you want to test your script you "Start Debugging" the tenscripting project and follow the form tenscripting presents to test and debug your code. When you are finished you "Export" your script from the tenscripting form. This is a quick and dirty explanation as this is outlined in great detail on the tenscripting site. Read it slowly and carefully as there's a lot of information there and it takes a while to get the hang of it.

          http://www.tenholder.net/tenWare2/te...g/Default.aspx

          Ken
          "if I have seen further [than others], it is by standing on the shoulders of giants." --Sir Isaac Newton (1675)

          Comment


            #35
            ok, my vb code is behind it in the forms page. I can read it there. So how do I ADD it to the tenscripting project. I see it in the solutions area, and I can click on it, but when I want to use the tenscripting project to select it, the dropdowns only point to his examples. I CAN sometimes see the "file" part shows my filename, but ...maybe a picture would help. I am attaching the picture. the tenholde project does not seem to be able to find my code I am writing behind it. Maybe I am not adding it to the project? How do I do that?
            Attached Files
            A computer's attention span is as long
            as it's powercord.

            Comment


              #36
              Try:

              Public Sub MySqlPutData




              You need to declare your routines as 'Public' so that tenScripting can find it.


              Hope this helps.

              tenholde
              tenholde

              Comment


                #37
                Making progress

                Thank you for the help.

                A couple of things I didnt realize...The .net script must reside in the same place you installed the tenscripting, and if you have another program in there that has the same Class name, it will tell you something about "A class with that name already exists."

                So I am getting further. I deleted the old program from that subdirectory, and then the project complained that it couldnt find it anymore. I selected it in the solutions list and then clicked on edit-->delete and now the tenscripting will run in debug mode again.

                so now, I am getting an error in the tenscripting log that says "Method 'tenscripting.Class1.Main' not found. But it is right there.

                Here is the program:
                -----------------------------------
                Imports System.Data.Odbc
                Public Class Class1
                Public Sub Main()
                Dim MyConString As String = ("DRIVER={MySQL ODBC 3.51 Driver};" & "SERVER=192.168.1.98;" & "DATABASE=Homeseer;" & "UID=root;" & "PASSWORD=wizard;" & "OPTION=3")
                Dim MyConnection As New OdbcConnection(MyConString)

                MyConnection.Open()
                Dim MyCommand As New OdbcCommand
                MyCommand.Connection = MyConnection
                MyCommand.CommandText = "insert into sayings(type,text) values ('Greeting','Welcome to our Home')"
                MyCommand.ExecuteNonQuery()
                MyConnection.Close()
                MyConnection.Dispose()
                End Sub
                End Class
                --------------------------

                I can see it there, but the project doesnt find it.
                I dont understand why it is not.

                Thank you again for your help. I really appreciate it.
                A computer's attention span is as long
                as it's powercord.

                Comment


                  #38
                  Try defining your SUB statement exactly as:

                  Public Sub Main(ByVal Parms As Object)


                  tenholde
                  tenholde

                  Comment


                    #39
                    Ok sir. That fixed that problem. Dont know why it is so picky. Thank you for your help. I will try to fix the other problems from here. I appreciate your help.
                    A computer's attention span is as long
                    as it's powercord.

                    Comment


                      #40
                      Let me know if I can help with any other issues.

                      The reason it is so particular, is that in order to load and call your script method dynamically, the function name and parameter format has to be specified, and if they don't match, the method cannot be found. It would add significantly to the complexity to try and match parameter call formats to the ones specified in the script, but it could be done. I haven't gone that far, because you are restricted to the way HomeSeer passes parameters to your script anyway.

                      Please let me know as you experience problems getting started. I think that once you get going, you'll see how much easier it is to write and debug complex scripts this way.

                      tenholde
                      tenholde

                      Comment


                        #41
                        Success

                        Thank you so much for your help. I also learned that if I am doing this in your development project, I have to get the mysql 3.51 driver and install it on my local machine where I am running the tenscripting. I did get it working. So I am posting the actual Homeseer event so others dont have to work through this like I did. This is only an "insert" example.
                        ---------------------------------------------------------------
                        Imports System.Data.odbc
                        Public Sub Main(ByVal Parms As Object)

                        Dim MyConString as string = ("DRIVER={MySQL ODBC 3.51 Driver};" & "SERVER=localhost;" & "DATABASE=Homeseer;" & "USER=root;" & "PASSWORD=xxxxx;" & "OPTION=3")
                        Dim MyConnection As New OdbcConnection(MyConString)
                        MyConnection.Open()
                        Dim MyCommand As New OdbcCommand
                        MyCommand.Connection = MyConnection
                        MyCommand.CommandText = "insert into sayings(type,text) values ('Greeting','Welcome to our Home')"
                        MyCommand.ExecuteNonQuery()
                        MyConnection.Close()
                        MyConnection.Dispose()

                        End Sub
                        ----------------------------------------------------------
                        Extra Notes:
                        You have to have already installed MySQL and setup a user you specify above to have access from '%' so the script can access the database or you get an error. Also, I had to go to MySQL and download the 3.51 driver. It can be found at: http://dev.mysql.com/downloads/connector/odbc/3.51.html. This must be installed on the Homeseer pc for the script to work when run from Homeseer. Also it must be installed on the development machine running the tenscripting. Good luck! (Seems so simple once you get the syntax right...)
                        A computer's attention span is as long
                        as it's powercord.

                        Comment

                        Working...
                        X