One of the knocks Smalltalk sometimes takes is the "doesn't play well with others" thing - the notion that it;s a world unto itself. I did a screencast showing how easy it is to hook ObjectStudio and iTunes up this morning - I thought a short post on it might be a worthwhile follow-up.
If you're working on a Mac, pretty much everything can be driven with AppleScript. On Windows, COM serves the same role. So if you fire up ObjectStudio, you can jump straight into that world of APIS by loading the OLE support:

Once you've done that, you can open a browser and define a new class. I just created one in the ObjectStudio namespace, descended from Object, and added one instance variable: 'dispatcher'. The example talks to iTunes (the Windows version). The #initialize method looks like this:
initialize
"Initialize a newly created instance. This method must answer the receiver."
| ole |
super initialize.
ole := OLEObject newProgId: 'iTunes.Application'.
dispatcher := ole dispatcher.
That 'dispatcher' object can now invoke various APIs that iTunes understands. So I created a workspace script to try things out:
| model |
model := ITunesModel new.
model setVolume: 100.
model play.
(Delay forSeconds: 10) wait.
model pause.
model nextTrack.
model play.
(Delay forSeconds: 10) wait.
model pause.
model release.
That sets the volume (a property), navigates to the next track, plays, and then pauses. The #release at the end does this:
release
super release.
dispatcher release
Since COM uses external Windows objects, we want to ensure that they get released. I'll be adding a simple ObjectStudio GUI to this tomorrow - stay tuned to Smalltalk Daily for that!
The important take-away here is this: using ObjectStudio 8, you get all the power and productivity of Smalltalk (including all of the VisualWorks libraries) - and you still get to play natively with the Windows APIs. That's why it's Vista Certified.
Technorati Tags:
objectstudio, com, windows