Owner's Manual (Complete)

Chapter 12 - Scripts
The Home Control Assistant
3
Test.
This starts the script engine to execute your script. Whatever action you have developed your
script to do will happen. The script engine and the max execution time is what was previously
configured in Script Setup. The name of the engine and max execution time is shown here for
your reference.
Also in this dialog is a checkbox to say if the Visual Program execution continues with the next
element immediately or waits until the script is complete.
Using scripts
Why use a script when Visual Programs have so many different elements that you can use? There
may be times where it simply is convenient to use a script rather than a visual program just because
of the number of elements you would need or your need to be kept up to date as your design
changes.
A good example of this is shown in a sample script included with the HCA installation. This is the
script AllHouseLightsOn.vbs
Option Explicit
Dim HCA
Set HCA = GetObject(,"HCA.Object")
Dim count
Dim i
Dim name
count = HCA.device.count()
For i = 0 To count - 1
name = HCA.device.Name(i)
if (HCA.device.SupportsDim(name)) then
HCA.device.On (name)
end if
Next
Set HCA = Nothing
This simple script turns on all the lights in your home. You may have one light or one hundred it
doesn’t matter. If you did have a hundred lights it would be a very large Visual Program and you
would have to update it each time you added or removed a light. With this script it is much
simpler.
Another reason is to perform some kind of test that HCA can’t do. For example, this script
determines if today is the 3
rd
Monday of the month.
Option Explicit
' Sets the rcScript variable in HCA to one if
' today is the 3rd Monday of the month
' Otherwise sets it to zero
Dim HCA
Set HCA = GetObject(,"HCA.Object")
Dim date
date = Now()
Dim y, m, d
y=Year(date)
m=Month(date)