Getting Started with Scripting


Excercise 6 - Substituting your own Smalltalk code

Here we will make a button that, when pressed, files out your current change set. This is to illustrate the fact that you can always "escape" from the tile-scripting framework to write your own arbitrary Smalltalk code.

Now chose "edit script textually" in the scriptor. This will give you a message-editing window in which you can type arbitrary Smalltalk code, and it will be invoked whenever the script is triggered, be it via ticking, mouse actions, or being called from another script.

So now we type in whatever script we want, in plain Smalltalk, and submit it. For the moment, you might edit the method to look like this:

doFileout
Transcript cr; nextPutAll: 'Testing One Two Three...'.
self beep: 'croak'.

Now make sure a Transcript is open, and then try the script out. When you click on the button, your message should show up in the Transcript and you should hear the croak.

This shows that the hookup is working. Now all that remains is to edit the method to do something useful; in this case, it will look like this:

doFileout
Smalltalk changes fileOut.
self beep: 'croak'

Now, whenever you click on this button, the current change set will be filed out and you will get a frogly confirmation.