System Language Extensions

The sys class provides extensions to VBScript which allow the core elements of the xPLHal server to be manipulated.

To set or return the current MODE

e.g. sys.setting("Mode") = sys_mode_occupied to set the mode to occupied
e.g. mymode = sys.setting("Mode") to return current mode
This is the only way you should change the mode - do not use sys.value to modify the global value directly.

To set or return the current PERIOD

e.g. sys.setting("Period") = sys_period_day to set the period to day
e.g. myperiod = sys.setting("Period") to return current period

To add a Single timed event

sys.SingleEvent(<dd/mm/yyyy hh:mm>, <vbscript sub to execute>, <parameter or "">, <tag name for identification>)
e.g. call sys.singleevent("21/09/2002 15:30","mysub", "", "pir 1")
This runs a vbscript called mysub at 3:30pm on the 21/09/02, then deletes the event
Note: if the tag already exists then the existing event is overwritten

To add a Recurring timed event

sys.RecurringEvent(<start time>, <end time>, <interval>, <randomisation>, <which days>, <sub to execute>, <parameter or "">, <tag name>, <overwrite>)

If the Overwrite parameter is set to True and an event with the same tag name already exists, it will be replaced by a recurring event with the new values.
If the parameter is false and an event with the same tag name exists, the call will return false and no action will be taken.


call sys.recurringevent("12:00","12:00",0,0,"0111110","mysub", "", "Lunch Time",True)
This runs a sub-routine called my sub at noon on weekdays

call sys.recurringevent("10:00","14:00",30,0,"1000001","mysub" ,"" , "something",True)
This runs a sub-routine called mysub at 30 minute intervals between 10am and 2pm at the weekends

To delete a timed event

sys.DeleteEvent(<tag name>)
e.g. call sys.deleteevent("Lunch Time")
This deletes the first event found with a tag of "Lunch Time"

To check if a timed event exists

sys.EventExists(<tag name>)
e.g. if sys.eventexists("PIR1")=True then ...

To save all events

All single and recurring events are saved when xPLHal is shut down, however the above function can be called to immediately write the events database to disk. By default, this function is called every 15 minutes as part of the xPLHalBackup event, which ensures that if the xPLHal server was to crash, any changes made to the events system would already have been committed to disk.

To return a web page

e.g. mypage = sys.gethttp("",32768)

To wait for a specified number of seconds

Where n is the number of seconds (between 1 and 60) that the script should wait before continuing it's execution.

To check for the existance of a global, or to delete a global

sys.exists(,) - returns true of false
e.g. status=sys.exists("TEST",false) 

To set a global value, create if it doesnt exist

e.g. sys.value("TEST2")=200
Note: xPLHal has to interpret the data type as string, numeric or date/time whenever a global
is created for the first time. Ensure that the first value written is of the correct type.

To get a global value

e.g. myvalue=sys.globalvalue("TEST3")

To disable an expired application

e.g. call sys.suspend("CallerID.Line1")
This is the default routine for the __Expired() script
If the app's heartbeat reappears later, then it is automatically set back to active.