SAM Jr Scripting Tutorial
First Things First
SAM Jr uses beanshell to handle it's scripting needs. If/when you need more information about the actual scripting you should look at the documentation on beanshell's site. This document will only skim the surface of what can be done and if you don't have some Java programming experience it will most certainly be very difficult to continue. In fact this document assumes that you are familiar with Java.
Quick Start Guide
The quickest and easiest way to get started is by locating the example.bsh file and editing it to suit your needs. This file is in $samjr_home/scripts. It includes methods for all currently available interfaces and one additional 'special' method. We will talk about the special method later. For right now just now that everytime an update happens on the screen all of these methods get called and which method you want to change depends on what information you are interested in. For instance if you want to do something everytime the alert level (low, medium, high) is changed you would add code to the alertLevelChanged(alertLevel) method. Simple right?
Possible Issues
There are several possible issues that you might have when you start to write scripts. First of all beanshell is not quite Java. Because beanshell is intended to be more of a scripting language you will notice that you don't have to declare your variables. Also, SAM Jr is still in a very early state and is not documented at all. To top it off SAM Jr will probably go through a rewrite since the code was written quickly and not well though out. To find out about the parameters that are passed in to the the methods you will need to download the source code from Source Forge and look through it. There aren't any javadocs at this time and probably won't be until the code gets cleaned up. Also, the impending rewrite will quite possibly break any code that you write in your scripts.
Special Method
There is a special method that should be included in every script. It's called invoke and it acts like a generic method. This allows you to write a script with only the methods you want and any other method calls will call this method. For instance if you want to write a script that only implements the change() method you can include the change() and invoke() methods and every other method call will go to the invoke() method which can be left empty. It also makes sure that should an interface be added in the future your script won't break.
Future Direction
In the future I plan to write some plugins that will allow programmers to get a better idea how to write plugins. Also much better documentation is planned which will make the process much easier.