Modes are used to define the different states that a house can be in. For example, occupied, unoccupied and sleeping.
You can configure the list of available modes through the Constructs tab of the xPLHal Properties dialog.
To view the properties dialog, in the xPLHal Manager, right-click on the name of your xPLHal server and select Properties.

You can use the Mode to customise the behaviour of your home automation system, depending on the state of your house. For example, if a PIR is triggered when the house is unoccupied, you may want to go into an alarm mode, and send an SMS to your mobile etc.
You would not however want this behaviour to occur if the house was occupied.

When xPLHal starts, it enumerates all configured modes, and assigns a numeric value to each.
These values are written to the script XPLHAL_SETTINGS.XPL in the Headers folder. This script file should not be edited manually, as it will be overwritten by xPLHal each time scripts are reloaded.

The definition of numeric values for the various modes will look something like the following:
' constants for mode
const sys_mode_empty=0
const sys_mode_occupied=1
const sys_mode_sleep=2

Determining the current mode

You can determine the current mode through use of the sys.setting("Mode") command, as shown below:
Dim CurrentMode
CurrentMode = sys.setting("Mode")
If CurrentMode = SYS_MODE_EMPTY Then
  ' The house is empty.
  ' The house is occupied.
End If

You can use the Mode property in combination with the Period setting to achieve a high degree of conditional logic in your scripts.