Code Snippets
Code snippets are small piece of code that illustrate a single function or piece of data. Complete applications, most with source code in C# or Flash, are available in the Sample Applications section.
There are three kinds of code snippets available:
- Expression Rules, which are triggered by timers or changes in asset state
- Groovy scripts that are called from Expression Rules
- Groovy scripts that are called from web services via Scripto
There is one snippet, Expression Rule Patterns for Alarms, illustrating how stacking of Expression Rules can do more than a single rule in isolation.
For scripts called by Expression Rules, the article on Groovy's Implicit Objects provides a good introduction to the variables which are supplied to your script by the platform. Depending on what kind of Expression Rule called the script, these variables can include the current alarm or location. The article includes pointers back to code snippets illustrating each case.
An important application of scripts is to call out to third-party web services. This is illustrated by two snippets: Send a Tweet, and Get Precipitation.
A good place to start with scripts called from web services via Scripto is the simplest code snippet, Retrieving a List of Models. You could also look at the HTML, Ajax and Scripto tutorial. If you have Flash Builder, the simple Hello Scripto sample application is a great introduction to calling Scripto scripts from Flash, as well as a simple way to test your Scripto scripts.

