WebRelay-10 Users Manual
Appendix G: BASIC Scripts
Date and Time Variables (WebRelay-10 Plus™ only)
The variables 'time' and 'date' are predefined, read only variables that store the current date and time.
They can be used to schedule events and activities, such as sending emails, reading temperature, or
setting relays. The date uses the mm/dd/yyyy format. Clock time is formatted as hh:mm:ss (24-hour
clock).
Example:
If date = 01/01/2014 Then
If time > 12:30:00 Then
Let relay2 = 1
Let relay3 = 0
End If
End If
Note: Current date and time can only be set in the
Date/Time
tab.
Event Variables (WebRelay-10 Plus™ only)
Up to five actions can be configured to occur at specified days and times. This is done by setting the day
and time of the event and then comparing it to the current date and time.
The event date variables are designated ed1 to ed5. They are set using the LET command and setting
the desired event date variable equal to the date the event should occur in the format mm/dd/yyyy. The
event date variables store the number of days that have passed since January 1, 1970.
The event time variables are designated et1 to et5. They are likewise set using the LET command and
setting the corresponding event time variable equal to the event time in the format hh:mm:ss in 24-hour
time. The event time variables store the number of seconds from the beginning of the day. If the event
time variable is incremented more than the number of seconds in a day (86400 seconds), the variable is
reset to 0 and the event date variable is incremented by one.
The following example demonstrates defining the event variables and comparing it to the current date
and time. Assume current time is April 10, 2010 at 1:30 AM and the event should occur in one hour and
every hour thereafter.
Example:
Let a = 1
Let ed1 = 04/10/2010
'sets the event date to April 10,
'2010.
Let et1 = 02:30:00
'sets the event time to 2:30
Do While a <> 0
If ed1 >= date Then
'Tests event date versus current date.
If et1 >= time Then
'Tests event time versus current time.
Let et1 = et1 + 3600
'Increments the event time by one hour
'(in seconds).
Print "Event"
'Event to occur
End If
End If
Loop
End
External Variables
There are five external variables, extvar0 through extvar4. External variables are similar to general
purpose variables and can be used in the same manner. The difference between general purpose
variables and external variables is that external variables can be accessed by the user through a web
browser and modified while the script is running. Scripts can use external variables as a method of
retrieving user input. The following example demonstrates this by creating a script that will turn Relay 1
ON
if extvar1 equals 1 and turn Relay 1
OFF
if extvar1 equals 0.
Xytronix Research & Design, Inc.
page 99
Содержание WebRelay-10 X-WR-10R12-I
Страница 1: ...WebRelay 10 Title Page Goes Here...