Monthly Archives: September 2006

Whilst packaging up a plugin based on the Skype API that I had been writing, I was looking for a way to bundle it all up cleanly. The finished plugin consisted of an .exe, a COM wrapper DLL (the very useful Skype4COM wrapper), and some HTML documentation for the C++ code (generated by doxygen). I thought this might be a good opportunity to have a look at NSIS, the installer generator that is used by a huge number of open-source (and other) projects.

My install requirements were quite simple. The following steps needed to be performed:

Copy the .exe and associated HTML docs to the target system;

Copy the COM DLL to the target system;

Register the COM server (by invoking regsvr32);

Create any necessary Start Menu items (and an uninstaller);

Open a web browser automatically on the index page documentation.

Obviously, the uninstaller would need to remove all files, and also unregister the COM server before uninstalling.

I downloaded NSIS from the web site and fired up the NSIS Compiler. This is a very simple interface that allows you to drag-and-drop .NSI script files into its interface and execute them. The NSIS scripting runtime is a very simple scripting language, with some basic language constructs, and the ability to define and import macros and plugins for extended functionality.
A screenshot of the compiler interface is shown below:

Here is the full installation script for my plugin, annotated with some comments.

The RegDLL and UnRegDLL directives will register and unregister a COM server on your behalf;

NSIS provides “hooks” at various points of the installer lifecycle. For instance, the splash screen in shown by the .onInit handler.

The ExecShell command (which seems to be a high-level wrapper around the ShellExecute function), can be used to open arbitrary files.

NSIS is a great application, and incredibly easy to pick up and use. The installers it produces are very slick looking, and can be extensively customised. It’s no wonder that this framework is now so popular.

I recently had the need to automatically retrieve and parse a table of BT fixed-line call tariff data. Normally I would use Perl for this sort of thing. However on this occasion, I decided this might be a good opportunity to learn a bit of Ruby.

# Send to stdout so we can run $ ./client.rb > tariffs.dat
puts tariffs

This produces a pipe-delimited output of call tariffs by country. My initial impressions of Ruby (I’m way behind the curve here) are:

It’s very “Perl-like” in some ways – you can see a definite Perl influence in the language.

I love the iterator and closure syntax: collect(), map(), etc. It’s very clean and intuitive.

The idea of code blocks as first-class objects seems to be integral to Ruby: in the code above, the output of a select {} block is passed to a collect {} block, which is passed in turn to another select {} block (all done within an each {} block). Very reminiscent of the simple building block approach of Unix shell commands.

There seems to be a lot of hype around Ruby at the moment, mainly driven by Rails. However, the basic language itself is quite exciting in that it seems to be as useful and concise as Perl, whilst having some syntactic advantages that make it more readable and maintainable.