Wednesday, September 09, 2009

Setting the title of a slide...

I've been playing around with two different presentation tools and found the different approaches to scripting to be quite interesting. The two scripts are shown below.


tell application "A"

set title of (current slide of first slideshow) to "Hello World"

end tell



tell application "B"

activate

set theIndex to slide index of slide of view of active window

set selectedSlide to slide theIndex of active presentation

set content of text range of text frame of shape 1 of selectedSlide to "Hello World"

end tell


The two scripts both set the title of the current slide to "Hello World". Its interesting to note that while "B" has more features the script is quite brittle, things like selecting the slide in the outline cause it to fail to select the current slide.

and the moral of the story is... "don't over engineer your code... keeping things simple with clean abstractions is always better"

No comments: