"COMPUTER POWER TO THE PEOPLE! DOWN WITH CYBERCRUD!" - Theodor Nelson
Saturday, September 27, 2003
OK, in my MS Agent Remote Control program I needed to record the actions that one can do to the agent object. I have an agent object that wraps the COM object. Here's an example of a public method that does some action that I need to be able to "record" and playback:
self control speak: aMessage
Now, self control returns the COM object. The method: #triggerCommandEvent is where things get interesting, though. Every method that needs to be recorded and played back calls this method first thing. Now, here's the implementation of the #triggerCommandEvent:
stackFrame := Processor activeProcess topFrame sender.
arguments: stackFrame arguments)
The thing I like about this is that there are several ways to do this, but being able to walk the stack allows you to do some rather elegant things and some less typing...=) Now, the above code is different in every Smalltalk, but you can do it. You can even do this concept in most dynamic languages. I know this isn't the greatest show of Smalltalk's abilities, but it's one of those things that I thought was nifty.