| Script & Plug-In Development Discuss scripting for HomeSeer and general VBScript assistance. Use this forum to post incomplete scripts, script snippets or code samples. |

November 16th, 2009, 06:23 AM
|
|
Viewer
|
|
Join Date: Nov 2009
Location: Norway, Bergen
Posts: 4
|
|
Learn to create script:
Where can I find the overview of the whole script language (.Txt file) to homesser?
I need to learn it.
What is the syntax to check whether the clock greater than 13?
|

November 16th, 2009, 06:35 AM
|
|
OverSeer
|
|
Join Date: Aug 2003
Location: FRANCE
Posts: 3,984
|
|
You should not use the .txt file syntax anymore. You'd better use the new .vb file syntax.
For this new VB.NET syntax, there are many sites with tutorials.
Just google for VB.NET tutorial or VB.NET reference
|

November 16th, 2009, 06:36 AM
|
|
OverSeer
|
|
Join Date: Aug 2003
Location: FRANCE
Posts: 3,984
|
|
If DateTime.Now.Hour > 13 Then ... End If
[EDIT] fixed a typo...
Last edited by stipus; November 18th, 2009 at 12:09 PM.
|

November 18th, 2009, 09:58 AM
|
|
Viewer
|
|
Join Date: Nov 2009
Location: Norway, Bergen
Posts: 4
|
|
I get the error on the dateTimeobject. Why?
Sub Main()
If DateTime.Now.Hours > 13 Then
hs.execx10 "Q1","off",0
end if
End Sub
|

November 18th, 2009, 10:46 AM
|
|
Seer Master
|
|
Join Date: Jun 2002
Posts: 946
|
|
Quote:
Originally Posted by Dagfinn Andestad
I get the error on the dateTimeobject. Why?
Sub Main()
If DateTime.Now.Hours > 13 Then
hs.execx10 "Q1","off",0
end if
End Sub
|
It should be DateTime.Now.Hour (singular)
If you were entering the statement in VS using tenScripting, intellisense should have made that obvious while you were entering the statement.
tenholde
|

November 18th, 2009, 11:03 AM
|
 |
OverSeer
|
|
Join Date: Jan 2002
Location: London UK
Posts: 5,384
|
|
You are mixing VBScript & VB.NET with the syntax used.
Sub Main(ByVal Parms As Object)
If DateTime.Now.Hour > 13 Then
hs.execx10 ("Q1","off",0)
end if
End Sub
This will run only when the script name has a .vb extension (not .txt)
If you want to do this in VBScript, it would become:
Sub Main()
If Hour(Time) > 13 Then
hs.execx10 "Q1","off",0
end if
End Sub
This would only run when the script name has a .txt extension
__________________
Jon
|

November 16th, 2009, 06:51 AM
|
 |
Seer Master
|
|
Join Date: Aug 2007
Location: Norway
Posts: 1,199
|
|
Se også her:
http://www.homeseer.com/support/home...2/homeseer.htm
Many years ago I read a "Teach yourself VB.net in 21 days" book. It was very good to explain the basics. The rest is just logic.
__________________
HSPro 2.4, RFXcom, Script Connector, BT connector, DI Connector, DooNetwork, HSTouch, WMP plugin, USB-UIRT, BLicon, DenonAVR, WebcamXP, Jon00s MaxiBee and Webpage builder
Using Twitter? Check out TwittSeer!
|

November 16th, 2009, 08:25 AM
|
 |
OverSeer
|
|
Join Date: Jan 2001
Location: Huntsville, Al. USA
Posts: 34,926
|
|
I disagree with Stipus, the vb script syntax is much easier to learn for beginners and both still work just fine. The best way to learn is go to the script library and look at existing scripts. The HomeSeer help files also have many examples for each scripting command as well.
__________________
-Rupp
Last edited by Rupp; November 16th, 2009 at 09:42 AM.
|

November 16th, 2009, 08:48 AM
|
|
OverSeer
|
|
Join Date: Aug 2003
Location: FRANCE
Posts: 3,984
|
|
One day you'll learn how to spell my name
You might be right, however the old syntax is just a language from the past.
Learning VB.Net might be usefull for many other systems...
|

November 16th, 2009, 09:12 AM
|
 |
Super Seer
|
|
Join Date: Feb 2006
Location: Rochester, NY
Posts: 1,736
|
|
Quote:
|
...the old syntax is just a language from the past.
|
I am torn by this statement. While true from the standpoint that it makes effective use of current OS capabilities, vb.net design is definitely not forward looking. As far as I can tell, it was munged together by a bunch of drunk C# programmers with no one having overall project design responsibility. Worse, they don't appear to have talked to one another, or at least couldn't decide on a common set of conventions for object class specifications. Worst, they turned the task of crafting error messages over to a robot with no prior experience!
From a usability and learning point of view, VBS is far superior. It is internally self consistent. It's documentation is comprehensive, and reasonably easy to understand. The language is inherently (by design!) quite forgiving, and when you make an error, it is usually helpful in identifying the problem and suggesting an appropriate solution.
If you plan to go anywhere with Visual Basic, you owe it to yourself to learn to use vb.net. If you are just starting out learning how to write a script. Your frustration level will be much lower if you begin with VBS.
__________________
Mike____________________________________________________________ __________________
HSPro 2.4.0.11 || Plug-ins: Stargate | ACRF2 | VWSCSV | UltraStatus | BLRFID | PowerTrigger | NetCam | ActiveBackup | UPB | mcsXap | UltraMon | Russound
Scripts: Weather XML | PerfMon | VDGraph | ImageBuilder
HW: EeeBox | JDS Stargate | NetworX NX-8E | CAV6.6 w ABUS | Slink-e / CDJ | Compose switches, keypads, firewalls | WGL800 | RFXCOM LAN2 | Quatech QSE100D | LaCrosse 2310
|

November 16th, 2009, 09:41 AM
|
 |
Seer Master
|
|
Join Date: Aug 2007
Location: Norway
Posts: 1,199
|
|
Quote:
Originally Posted by Uncle Michael
Your frustration level will be much lower if you begin with VBS.
|
I disagree.
I started with VBA and VBS around the time when .NET Framework version 1.0 came along. I was thrilled with the switch to .NET. Finally some structure and logic!
But... we can't all like the same things. And thankfully we don't.
__________________
HSPro 2.4, RFXcom, Script Connector, BT connector, DI Connector, DooNetwork, HSTouch, WMP plugin, USB-UIRT, BLicon, DenonAVR, WebcamXP, Jon00s MaxiBee and Webpage builder
Using Twitter? Check out TwittSeer!
|

November 16th, 2009, 09:45 AM
|
 |
OverSeer
|
|
Join Date: Jan 2001
Location: Huntsville, Al. USA
Posts: 34,926
|
|
Quote:
Originally Posted by stipus
One day you'll learn how to spell my name
Learning VB.Net might be usefull for many other systems...
|
I fixed my misspelling
This is true but for the true beginner sometimes jumping into .net is a bit daunting and they give up. The beauty of vbs is the beginner doesn't have to worry about defining each variable type. This can be bad but when learning it make things a ton easier.
__________________
-Rupp
|

November 16th, 2009, 09:52 AM
|
 |
Seer Master
|
|
Join Date: Aug 2007
Location: Norway
Posts: 1,199
|
|
Quote:
Originally Posted by Rupp
The beauty of vbs is the beginner doesn't have to worry about defining each variable type.
|
And that is something that is wrong with VBS. The sooner people learn to declare their variables, the better. It just makes more readable code (especially when the code gets complicated, which probably is going to happen if you like HomeSeer  ).
Developing .NET scripts with tenScripting is extremely easy! 
Just download VB.NET Express and off you go!
__________________
HSPro 2.4, RFXcom, Script Connector, BT connector, DI Connector, DooNetwork, HSTouch, WMP plugin, USB-UIRT, BLicon, DenonAVR, WebcamXP, Jon00s MaxiBee and Webpage builder
Using Twitter? Check out TwittSeer!
Last edited by Moskus; November 16th, 2009 at 10:21 AM.
Reason: spelling
|

November 16th, 2009, 10:20 AM
|
 |
Super Seer
|
|
Join Date: May 2001
Location: Brookhaven, MS USA
Posts: 1,723
|
|
If I had to do it over again, I wish I had not gone VBS first. Coding in VB.NET is much easier with tenScripting. Enforcing variable type and definition is key for good programming practices.
Another reason is single vs multi-threading. When you have multiple scripts firing at the top of every hour, etc. you're better off having VB.NET scripts.
__________________
Dell Inspiron 1010 Atom 1.33Ghz / 1G RAM
HSPRO 2.4.0.59/ Z-Troller v1.15 / Z-Wave devices / 2 WDTC-20 thermostats
TI-103 / WGL800 / RFXCom~AC-RF2 / Oregon Scientific Sensors / Motion Sensors / X10 devices / DS10a
Check out Homeseer's YouTube Channel!
|

November 16th, 2009, 12:03 PM
|
 |
Super Seer
|
|
Join Date: Feb 2006
Location: Rochester, NY
Posts: 1,736
|
|
Quote:
Originally Posted by Moskus
And that is something that is wrong with VBS. The sooner people learn to declare their variables, the better. It just makes more readable code (especially when the code gets complicated, which probably is going to happen if you like HomeSeer ).
Developing .NET scripts with tenScripting is extremely easy!
Just download VB.NET Express and off you go!
|
I mostly agree. But, although my earlier rant was deliberately exaggerated, I still think it is much easier to start with VBS for simple scripts. VBS was designed for casual programmers. Learning to use it is mostly a learn by example process. Because it is limited in scope, the pertinent examples are relatively easy to capture in a guide book of approachable size.
Vb.net is clearly much more structured and much more capable than VBS, and I've converted nearly all my VBS scripts to vb.net thanks in large part to tenScripting. (A godsend! Without it, I would still be at square -1.  ) That said, I still find that opening a separate application to create a simple script is not that appealing, and I usually start by trying to adapt an existing script in Notepad when I need to create something new. I also find the class structure very confusing. I usually cannot predict which class contains which functionality, and have not found any guides that have been useful - except to ask on this board for help.
That is really my point. If you are dedicated to programming and study vb.net closely, I'm sure it becomes second nature. For those of us who come to HA from other fields, and who see scripting as a necessary evil to accomplish something we consider useful, it is not transparent at all. We still need concrete examples to get started. But, vb.net is so powerful and so comprehensive it is overwhelming for simple tasks. It feels like driving a tractor trailer to get to the corner store.
Quote:
|
Once your script is working correctly, ONLY THEN do you export it into your HomeSeer Script directory for production use.
|
Unfortunately, either I don't fully understand how to use the tool or I'm really incompetent (or both  ), but I find that my most annoying errors are those that involve interactions within the HS environment, and they only surface AFTER I've installed the script and run in for a few cycles - maybe over a few days or weeks - to discover the subtle bugs in my logic. Unfortunately, vb.net didn't change that.
__________________
Mike____________________________________________________________ __________________
HSPro 2.4.0.11 || Plug-ins: Stargate | ACRF2 | VWSCSV | UltraStatus | BLRFID | PowerTrigger | NetCam | ActiveBackup | UPB | mcsXap | UltraMon | Russound
Scripts: Weather XML | PerfMon | VDGraph | ImageBuilder
HW: EeeBox | JDS Stargate | NetworX NX-8E | CAV6.6 w ABUS | Slink-e / CDJ | Compose switches, keypads, firewalls | WGL800 | RFXCOM LAN2 | Quatech QSE100D | LaCrosse 2310
|

November 16th, 2009, 09:07 AM
|
 |
Seer Master
|
|
Join Date: Aug 2007
Location: Norway
Posts: 1,199
|
|
Quote:
Originally Posted by Rupp
I disagree with Stupis, the vb script syntax is much easier to learn for beginners and both still work just fine.
|
The VB script syntax is outdated and should have been removed from HomeSeer a long time ago. In my opinion it's also harder to learn as it's not as logical as .NET is.
Go the .NET route, you won't regret it.
__________________
HSPro 2.4, RFXcom, Script Connector, BT connector, DI Connector, DooNetwork, HSTouch, WMP plugin, USB-UIRT, BLicon, DenonAVR, WebcamXP, Jon00s MaxiBee and Webpage builder
Using Twitter? Check out TwittSeer!
|
| Thread Tools |
|
|
| Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is On
|
|
|
All times are GMT -4. The time now is 09:27 PM.
|