Originally posted by B1Trash
View Post
Announcement
Collapse
No announcement yet.
Scripts with common subroutine
Collapse
X
-
-
Not a coder, just grasping at straws, but I remember having trouble getting some of my cut-and-paste scripts to work until I got this line correct in my config.ini file. Could that be it?
ScriptingReferences=System.Web;System.Web.dll;System.Web.Ext ensions;System.Web.Extensions.dllHomeSeer Version: HS4 Pro Edition 4.2.19.0 (Windows - Running as a Service)
Home Assistant 2024.3
Operating System: Microsoft Windows 11 Pro - Desktop
Z-Wave Devices via two Z-Net G3s
Zigbee Devices via RaspBee on RPi 3b+
WiFi Devices via Internal Router.
Enabled Plug-Ins
AK GoogleCalendar 4.0.4.16,AK HomeAssistant 4.0.1.23,AK SmartDevice 4.0.5.1,AK Weather 4.0.5.181,AmbientWeather 3.0.1.9,Big6 3.44.0.0,BLBackup 2.0.64.0,BLGData 3.0.55.0,BLLock 3.0.39.0,BLUPS 2.0.26.0,Device History 4.5.1.1,EasyTrigger 3.0.0.76,Harmony Hub 4.0.14.0,HSBuddy 4.51.303.0,JowiHue 4.1.4.0,LG ThinQ 4.0.26.0,ONVIF Events 1.0.0.5,SDJ-Health 3.1.1.9,TPLinkSmartHome4 2022.12.30.0,UltraCID3 3.0.6681.34300,Z-Wave 4.1.3.0
Comment
-
Guest
There may be a little confusion over what the "include" statement does. What is does is to insert the contents (the actual text) of the include file, at the spot where the include statement is.
Say that a file x.vb constains:
Code:Private Function Foo() As Boolean Return True End Function
Code:#include x.vb Sub Main(parms As Object) If Foo() Then hs.WriteLog("Foo", "Is True") End Sub
Code:Private Function Foo() As Boolean Return True End Function Sub Main(parms As Object) If Foo() Then hs.WriteLog("Foo", "Is True") End Sub
(Actually there are ways to have a compiled object code library, but doing so is way too complicated to describe here, and way to much trouble to do anyway).
Comment
-
As I'm the person having the #include issue, I appreciate the explanation of how it's suppose to work. I tried your example but the script errored out with 'foo not declared'. I suspect I might not have the correct scripting reference as suggested above. I'd try it, but I already have so many scripting references that it runs off the page.Don
Comment
-
Guest
Originally posted by donstephens View PostAs I'm the person having the #include issue, I appreciate the explanation of how it's suppose to work. I tried your example but the script errored out with 'foo not declared'. I suspect I might not have the correct scripting reference as suggested above. I'd try it, but I already have so many scripting references that it runs off the page.
Comment
-
Originally posted by donstephens View PostAs I'm the person having the #include issue, I appreciate the explanation of how it's suppose to work. I tried your example but the script errored out with 'foo not declared'. I suspect I might not have the correct scripting reference as suggested above. I'd try it, but I already have so many scripting references that it runs off the page.
Comment
-
Originally posted by aa6vh View Post
Maybe you could show us the two files (the contents of the #include file and the contents of the script that includes it). Based on some of the previous posts in this thread, it may be as simple as misplaced text causing a syntax error (HS's vb .net is notorious for giving poor error messages).Don
Comment
-
Guest
Originally posted by donstephens View Post
I was using the example given in post #36.
What I do using the web interface is create a dummy event (manually executed) that invokes a single script action, and then specify my "library" source stuff for that script file. (Rather than create a dummy event, you could use an existing event and simply set the "Never" option on that script action to keep it from actually running).
Make sure that the script files are exactly as shown, do not "embellish" them until you get it working! Create a dummy event just running script "x.vb", then another event running the main script.
Comment
-
Originally posted by aa6vh View Post
Okay. Now I have to ask how are you creating those script files? Directly on the Homseer server system, or through the web interface?
I'm using notepad++ on a remote machine saving to the HomeSeer/scripts directory
test2.vb
PHP Code:#include x.vb
Sub Main(parms As Object)
If Foo() Then hs.WriteLog("Foo", "Is True")
End Sub
PHP Code:Sub Main(byVal Args As String)
End Sub
Private Function Foo() As Boolean
Return True
End Function
Don
Comment
Comment