No announcement yet.

Scripts with common subroutine

  • Filter
  • Time
  • Show
Clear All
new posts

    aa6vh your discovery is consistent with the same issue I had. Homeseer likely discards the compiled p code on exit (or flags it as such), requiring a recompile on first run of the script after product launch. That itself is not bad practice on the part of HS, as it allows for product upgrades without introducing potential script run-time errors. If first call to the script after launch happens to be an event trigger, you wouldn't notice the problem. If it's hs.runscriptfunc, the compiler will ignore the #includes statement. I haven't tested what happens if you issue an hs.triggerevent call on HS launch to manually launch the script via an event, but I'm assuming that would actually work as well.

    It appears to me is that events that run scripts will load and save a version of the uncompiled vbscript code in memory - I found this out the hard way yesterday when HS overwrote a day's worth of work with an outdated version of a script it had loaded onto it's "edit" screen (and yes- I was cursing for 30 minutes, btw). Thankfully, I remembered most of what I had done.


      I do all of my script development on my main computer system, not on the Homeseer server. So I keep all of the script files in text files on my main computer (i.e. using something like Notepad to edit them), then simply copy and paste the script into the browser script edit box. Doing it this way ensures that I do not loose the script when the browser decides to use a cached version of the edit box. And I can also edit and ponder the script without having to access Homeseer. And it is easier to manage if wanting to use some other mechanism for testing your script, such as that tenscripting app (I had developed another, much cruder version of tenscripting before tenscripting was invented).

      As far as rebooting goes, my current plan to is to write a script that will "open" the script files for output, immediately close them (so that the "recompile" flag gets set), then add to my "Homeseer Launched" event actions that will run that script, then run each individual script file. That should get everything recompiled and ready for use. (I am just waiting to get a "round toit").