Scripts provide real flexibility in all good automation systems. Xtension scripts are written in Apple's standard scripting language AppleScript, and can be simple or very complex.
XTension provides several verbs and nouns, and AppleScript provides an extensive dictionary of verbs and constructs.
XTension calls upon the AppleScript compiler to test and execute scripts, and the AppleScript server calls upon XTension to process phrases that it serves. Therefore, you may integrate XTension functions into scripts which span widely different systems and applications.
For example you might have a script for an accounts receivable system which tells XTension to ring a bell each time you add another $1000 to your total income. Or, gather callerID information in another application, and have XTension put the entry in the log and sound alarms (or not) according to who is calling.
Using XTension and AppleScript you can personalize a home system or create a complete facility management system for a shopping mall or greenhouse.
Ignoring all of the infra-structure beneath them, each script in itself is a tiny program. It's purpose is either to react to some autonomous event such as a movement sensor, or to guard any attempted change to some controlled device such as a hot plate.
If a movement sensor indicates an alarm state, we may want to do more than just turn on a light. Devices exist of course which do this automatically, but you still want XTension to notice and change the unit status in the database and perhaps take action.
You may want to do different things according to the time of day or day of the week or whether other movement sensors have indicated that there hasn't been movement “inside” for more than an hour.
Sometimes it is useful to have common scripts which can be executed on demand.
The Scripts menu of XTension allows you to create a Global Script, give it a name and save it so that it is available in the menu or to any other script on demand.
These scripts are called Global Scripts because they can be executed from the menu and from other scripts.
There are special names you can give global scripts that will tell XTension to run them under special circumstances. For example if you create a global script named “Startup Script”, XTension will run it everytime that XTension starts up. Likewise, the script name “Shutdown Script” will be executed any time that XTension is told to quit. Neither of these script is required, however you find useful applications for them.
See the Special Scripts section for more info about these.
The MacOS provides a powerful scripting facility with AppleScript. Almost anything that can be one with a Mac or Mac application can be controlled or enhanced by scripts which can in themselves be “applets”.
Many common verbs and conditional constructs are provided by AppleScript, while applications can publish dictionaries of their own verbs for special functions.
It is even possible for you to create additional “commands” which are just other scripts (like subroutines)!
There are AppleScript editors from Apple and third parties which an record actions and compose scripts to perform some very complex functions.
XTension provides a simple script editor which is sufficient for writing scripts for your automation system, thus you do not need to use an external script editor. YOu may of course write scripts in any script editor and import them into XTension. Scripts created by XTension may be opened and read by any other AppleScript editor.
You do not need to be an AppleScript guru to write scripts for XTension. Most of the scripts you will write only need simple if/then/else statements along with verbs and constructs from XTension's dictionary.
if value of "Temperature" is greater than 70 turn off "Heater" else turn on "Heater" end if --this is a stupid example, just shows simple form