Announcement

Collapse
No announcement yet.

Using objects in scripts

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

    Using objects in scripts

    I want to make sure I have the right understanding of how to write and use objects in scripts.

    First, you can't instantiate an object which you've defined in a seperate script file. runex, etc, can only run subs or functions. You can only instantiate an object from within same the file in which it has been defined.

    Second, in order to access your objects from an external file, you need to compile them into an assembly and add a reference to it in ScriptingReferences section of the settings.ini file. There's no other way it can be done.

    Do I have it right?
    Last edited by RegForte; June 6, 2009, 06:17 PM.

    #2
    As far as I know all of this seems correct...

    I wish there were another way to do this as well, I don't really like to keep updating DLL's as my objects are likely to change just as much as the script.

    I sure wish we could just use imports at the top of a script file instead of adding it to the script references.

    I think if you were to use the script connector plug-in you might be able to get around of some of this stuff. I might take a second look at that as well.
    Joe (zimmer62)

    BLSecurtiy, AC-RF2, RCS Serial Thermostats, RFXCOM SMarthome SwitchLinc, mcsXap, Global Cache GC100, SqueezeBox, TWA_ONKYOINTEGRA, BLLogMonitor, BLPlugins, BLRadar, BLSpeech, BLZLog.aspx, HSTouch (Windows, iPhone, iPod), USB Mimo touchscreens, VMWare Server, Vortexbox, Windows Home Server, MyMovies, Windows Media Center, X10, ZWave, and much much much more.

    Comment


      #3
      Thanks, Joe. I'll take a look at the script connector.

      Comment


        #4
        How about an hs global variable

        Could you use the he.savevar and hs.getvar to create a global variable to pass around the object.

        not sure if I have the method names correct
        Mark

        HS3 Pro 3.0.0.534
        Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway
        Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 (by Kirby) | Ultra1Wire3 | RFXCOM | NetCAM | MyQ | BLRadar | BLDenon | Jon00 Charting
        Platform: HP h8-1360t, Windows Server 2012 R2, i7-3.4GHz, 16GB memory

        Comment


          #5
          savevar:

          Will that work with an object that you've defined in one script, and then try and access it from another script.

          I guess I could try it out, just assumed that it wouldn't...
          Joe (zimmer62)

          BLSecurtiy, AC-RF2, RCS Serial Thermostats, RFXCOM SMarthome SwitchLinc, mcsXap, Global Cache GC100, SqueezeBox, TWA_ONKYOINTEGRA, BLLogMonitor, BLPlugins, BLRadar, BLSpeech, BLZLog.aspx, HSTouch (Windows, iPhone, iPod), USB Mimo touchscreens, VMWare Server, Vortexbox, Windows Home Server, MyMovies, Windows Media Center, X10, ZWave, and much much much more.

          Comment


            #6
            Originally posted by zimmer62 View Post
            savevar:

            Will that work with an object that you've defined in one script, and then try and access it from another script.

            I guess I could try it out, just assumed that it wouldn't...
            the create method is CreateVar and it is supposes to create a hs global variable just like the object "hs". so you should be able to access it via any script that is running within hs.

            once you createvar, you can use getvar in the second script and even savevar to change the value

            deletevar will destroy the object

            good luck, let us know
            Mark

            HS3 Pro 3.0.0.534
            Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway
            Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 (by Kirby) | Ultra1Wire3 | RFXCOM | NetCAM | MyQ | BLRadar | BLDenon | Jon00 Charting
            Platform: HP h8-1360t, Windows Server 2012 R2, i7-3.4GHz, 16GB memory

            Comment

            Working...
            X