Announcement

Collapse
No announcement yet.

tenScripting 3.22 Now Available

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

    #16
    The Imports statement does work with tenScripting with a small footnote. In tenScripting, you may place multiple scripts within a single .vb file, each defined as a separate Class. For your script when it is exported to HomeSeer, any Imports statements must be defined at the front of the script file. You cannot place these Imports statements at the front of your class in tenScripting that defines your script, as they must be at the top of the .vb file, before the definition of all of the scripts (Classes) contained in the file. The simple workaround is that you place the Imports statements for ALL of the scripts defined in any of the script Classes at the beginning of the tenScripting file, and when you export a single script to HomeSeer, tenScripting copies the Import statements at the top of the file to the front of your exported script. This, however, isn't really the issue here.

    The #Include statement is a relic from pre .net days, and no longer exists in VB.NET. Apparently HS does some preprocessing before compiling each script that processes the #Include statement. So, no, tenScripting does not support the #Include statement (because MS Visual Studio does not). It might be feasible for me to preprocess #Include statements in tenScripting, but I can see issues trying to debug from the source.

    The .net way to reuse code is to compile the common code into a separate .dll and then add a reference to it. This is not as hard as it sounds.

    If just reuse is the issue, I recommend placing all of the scripts that you intend to reference the common code into a single HS script, with multiple entry points that are called by your events just as you would call the Main sub. Each of these entry points could reference one or more Private routines in the same script. See that last code example on this page: http://tenholder.net/tenWare2/tenScr...4/Scripts.aspx
    tenholde

    Comment


      #17
      Thanks for looking at it and providing the explanation. Code reuse is my goal so I'll investigate the VS compatible options.

      Comment


        #18
        Originally posted by tenholde View Post

        The .NET way to reuse code is to compile the common code into a separate .dll and then add a reference to it. This is not as hard as it sounds.

        tenholde I worked through how to compile a personal dll with common code and can reference it. I do have one problem I'm not experienced enough to work through and was hoping you could provide some advice. In my DLL any code that references hs.mumble calls fail as the hs object isn't initialized. I can see that initializing the hs object is done automatically in tenScripting3 but I can't quite figure out how to migrate that to my DLL. Can you suggest some code that will work?

        Naturally anyone else who has a potential solution can chime in as well, I'd appreciate the assist. Thanks in advance!

        Comment


          #19
          https://forums.homeseer.com/forum/de...s4-fails/page3

          tenholde

          Comment


            #20
            Thanks. I had actually saved that code and considered it in this problem, but I struggle with how this would work in the context of both running in tenscripting3 or running directly in an event in HS3. I'm guessing when running natively as executed by an event, the "remote script" code isn't necessary. Not sure it would make sense as a universal solution. I'll keep thinking about it. I may just eliminate HomeSeer object functions from the DLL code.

            Comment


              #21
              Have visual studio and tenscript4 installed. I can get C# to work and write simple code. How do I get the Homeseer scripting window open?
              Jeff​

              Comment


                #22
                Originally posted by retiredjeff View Post
                Have visual studio and tenscript4 installed. I can get C# to work and write simple code. How do I get the Homeseer scripting window open?
                Jeff​
                What version of Visual Studio are you using. What version of HS, and what version of tenScripting.

                Are you able to write simpe C# code via tenScripting4? What do you mean by HomeSeer scripting window?
                tenholde

                Comment


                  #23
                  Visual Studio v 17.4.1 HomeSeer HS4 ZEE S2 (Upg from HS3ZS2) Edition 4.2.16.0 (Linux) The download file was tenscripting 4_12. I have it unziped but don''t know if it is installed. When I click on open projects or solutions in visual studio, it points to the tenscripting4 file folder containing the unziped files. I was referring to tenscripting program window.

                  Comment


                    #24
                    Guests arriving for TG, will try and record a video for you this evening
                    tenholde

                    Comment


                      #25
                      Thank you. Take the day off and enjoy.

                      Comment


                        #26
                        While these videos are for version 3, they should give you an idea of how to get this all working.
                        http://tenholder.net/tenWare2/tenScripting/Videos.aspx

                        Let me know if this helps
                        tenholde

                        Comment


                          #27
                          Also, make sure you have read all of the topics located at:
                          http://tenholder.net/tenWare2/tenScr...4/default.aspx


                          tenholde

                          Comment


                            #28
                            Followed vids and got to the start button. Did not get any of the errors you showed but got a visual studio error. Click image for larger version

Name:	image.png
Views:	60
Size:	133.0 KB
ID:	1577354

                            Comment


                              #29
                              From your post, looks like your VS solution is goofy. CsScripts looks like it is the solution instead of tenscripting. Did you first load and run just the distributed solution files? Then add your script files to the CsScripts project?
                              tenholde

                              Comment


                                #30
                                don't know what I did. Maybe I should uninstall everything and start from scratch following the vids.

                                Comment

                                Working...
                                X