There is a tutorial on scripting in the scriptorium here at the Org which shows how to do this. Perhaps, if you cannot get the tutorials to work, you may wish to post back here...