Monthly Archives: January 2014

Last updated by at .

Compiled HTML Help and Online Help Documents

All my products ship with documentation in the form of a compiled HTML (CHM) file. I also provide the same content online. Maintaining the two different HTML projects was always a pain which I could have solved through the use of a third party tool like Help and Manual. But I am cheap and a few years ago I hit on a solution that allows me to maintain a single copy of my documentation and build it to a compiled help file or upload it as HTML to a website.

Tag the HTML

My individual help files (which are all just HTML files) are littered with custom tags encapsulated within HTML comment tags. So, for example when my help files are displayed online I like to display a simple menu at the top of each page, but I do not want this appearing in the CHM version. So the top of the HTML body in all my documentation HTML files looks something like this:

<body> 
<table width='100%' border=0 bgcolor=#6699cc> 
  <tr> 
    <td width='100%'> 
    <h1>Help Topic Name Goes Here</h1> 
  </td> 
  </tr>
<!--insert php here-->
</table>

Note the “insert php here” tag in the HTML comments.

Search and Replace at Build Time

When I am ready to build a new version of the software (and compile a new CHM file and upload documentation in HTML form) I just need to search and replace the HTML using the free tool FART (Find And Replace Tool). Here’s some of the relevant lines out of my build script (which is just a DOS batch file).

@ECHO BUILDING HELP FILE
"d:\Program Files (x86)\HTML Help Workshop\hhc" "d:\Path\To\HTML\HelpProject\help.hhp"
ECHO Deleting old online help files
delete "d:\Path\To\Online\Help\Files\*.htm"
ECHO Copying help files to online help directory
copy "d:\Path\To\HTML\HelpProject\html" "d:\Path\To\Online\Help\Files\"
ECHO Replacing place holders with PHP
fart -q "d:\Path\To\Online\Help\Files\*.htm" "<!--insert php here-->" "<?php include('inc/header.php');?>"
fart -q "d:\Path\To\Online\Help\Files\*.htm" "</head>" "<?php include('inc/google-tracking.php');?>"
fart -q "d:\Path\To\Online\Help\Files\*.htm" "<script src='scripts/footer.js'></script>" "<?php include('inc/footer.php');?>"
@ECHO FTPing FILES TO WEB SERVER
"d:\Path\To\WinSCP\winscp.exe" /console /script=winscp-ftp-help-file.txt ftp_login:ftp_password@ftp.somesite.com

Line 1 compiles the CHM file. I use good old HTML Help Workshop from Microsoft to do this. It works well and but I maintain all of the project files in a text editor because the GUI is awful.
Line 4 deletes the old temporary copy of the online HTML files.
Line 6 makes a copy of the HTML files into the temporary online HTML location.
Lines 8-10 uses the FART tool to do the search and replaces. Note that I’ve replaced a custom tag with a php_include, replaced the </head> tag with a php include that generates Google Analytics code (and puts the </head> back), and finally replaced a js footer with a PHP equivalent.
Line 12 uses the very neat WINSCP command line SFTP tool to upload the files.

So, there you have it. One set of HTML files can be used to generate a CHM file using HTML Help Workshop and to generate online HTML files. It works very well and automating the process using tools like FART and WINSCP have made my build and release process a snap.

Checking and Setting an INI Entry in Innosetup

Here’s a handy bit of code I wrote today for checking and setting an INI entry using the free setup compiler, Innosetup.

procedure CurStepChanged(CurStep: TSetupStep);
  var 
    sFirstRun: string;
begin
    if CurStep = ssDone then
      begin
          sFirstRun:=GetIniString('FirstRun','FirstRun','0',ExpandConstant('{commonappdata}')+'\AppName\appname.ini');
          if sFirstRun<>'1' then //we are doing a clean install of version 5 set version 5 database updates to 1 to stop upgrade prompt.
            begin
              SetIniString('IniSection','KeyName','1',ExpandConstant('{commonappdata}')+'\AppName\appname.ini');
            end;
      end;
end;

A key thing to note here are that the code is living in the CurStepChanged event and I’m checking that CurStep=ssDone. ssDone represents the successful completion of the installation process. Another item of interest is the ExpandConstant function which is used to access the in-built constants that Innosetup offers.

The reason I’m using this code is to differentiate between a clean install of a program and an install over the top of an existing installation. When any of my programs runs for the first time I write a key (usually FirstRun into section FirstRun) into an ini file. If this key is present then the software has been run at least once. If it’s not present then the installation is a clean one. I can then write an ini entry if it’s a clean install.

Dredd Movie Review

Dredd 2012 Movie Poster

The 2012 movie Dredd came and went having barely registered a blip on my radar. This was for a couple of reasons. It was a big time for comic cross-over films (think The Avengers and The Amazing Spiderman) and I can distinctly remember being quite bored with most of them. That, and the fact that I loathed the 1995 “Judge Dredd” starring Sly Stallone left me less than motivated to see this new imagining of Dredd about which I had heard nothing. A friend of mine went along to see it and afterwards told me that I should take a look. It took me more than a year but last December I watched the DVD and was (very) impressed. I watched it again yesterday and was impressed again, impressed enough to pen this review.

The movie itself depicts a dystopian, post nuclear holocaust future where mankind is huddled into “mega-cities” with populations of nearly a billion people. “Mega-City One” is depicted in the movie as a sprawling walled city that looks for all the world like Los Angeles but sprinkled with towering 200 story apartment blocks that house 50,000 plus people. As you’d imagine such an environment has rampant crime (with more than 17,000 crimes reported daily according to a voice-over), extreme poverty and unemployment, and plot-device appropriate highly addictive narcotics. Law in Mega City One is enforced by “judges” who act as police officer, juror, judge, and in some cases executioner when a “perp” deserves such justice. These one man (or woman) armies ride around on motorcycles (the Lawmaster) dispensing justice with their sophisticated side-arm (the Lawgiver). They wear black armour and a face covering helmet that makes them look for all the world like slightly grungy Darth Vader wannabees.

That all sounds pretty grim and with almost all comic book cross-over movies depicting a some sort of bleak future with a troubled hero it seems almost de-rigueur. But unlike so many other movies Dredd is faithful to the source material, and if anything, guilty of perhaps underselling how bad life in a mega city might be. And Judge Dredd (for whom the movie is named) is not your typical angsty troubled super-hero of the last 15 years. He’s a cold, imposing bad-ass. Karl Urban (who we know from the Lord of the Rings trilogy, the Star Trek reboots, and a couple of the Bourne movies) plays Dredd as an anonymous, incorruptible, unstoppable figure who cuts a path through this movie like an elemental force. When the helmeted Urban (we never see his entire face during the movie) announces over a PA system that “I am the Law” I grinned in anticipation at the mayhem that would ensue. When Sylvester Stallone uttered the same words in the execrable 1995 “Judge Dredd” he sounded like a brain damaged Rocky Balboa. While we’re talking about actors, there’s a couple of others I recognised in this movie. There’s Lena Headley (from The 300 and The Game of Thrones) who plays the scar-faced gang leader “Ma-Ma” and Olivia Thirlby who we saw in Juno and the neat Russian sci-fi movie, The Darkest Hour. Thirlby plays Dredd’s psychic rookie partner “Judge Anderson” who is a recurring character in the 2000AD source material.

The movie itself has a basic plot (which I won’t bother talking about) and a grim and grimy appearance. Most of the action takes place in one of the 200 story mega towers called Peach Trees and when I say action I mean action. There’s a lot of it and most of it is both visually spectacular and confronting. This is not a movie for the squeamish. Some of the deaths depicted are fairly horrific. The special effects appeared to be mostly practical (not much CGI to see here) with costumes, props, and weapons being fairly recognisable. It’s not hard to see the technology depicted in this movie being available just 10 or 20 years from now. This makes it a lot more involving for me, as compared with for example, the technology depicted the recent (and enjoyable) movie, Oblivion.

Two viewings of the movie have left me wanting to get my hands on some 2000AD comics. I read a number of them in my early teens and I can remember them being grim, gory affairs and quite distinct to the other comics I happened to be reading at the time. It’s also left me wanting to watch the movie again because I actually found the second viewing quite a bit more fun than the first. A sequel would be great too but given the poor box-office that’s highly unlikely.  There is bit of a campaign by fans to get a sequel made including a Make a Dredd Sequel Facebook page and I can only wish them best of luck. Dredd is a look at what is an unlikely future but a future that is easily understood by anyone from modern western society. It’s visually confronting and has a superb depiction of a classic comic book hero. Sure the plot is simple but one cannot help but enjoy the ride on the shoulders of Judge Dredd as he dispenses justice without bias or favour. If you’re a fan of sci-fi and don’t mind a bit of gore then I cannot recommend Dredd any more highly.

WordPress vs Movable Type Six Weeks Later

It’s now been almost 6 weeks since I moved this blog from the Movable Type platform to WordPress. I made the move mainly because I prefer WP. However, I was interested at the time to see if WP performed any better with regards to Google organic search traffic because people always rave about how wonderfully WP can perform in SERPS when used with the Yoast SEO plugin. I must confess that I didn’t do much (or any really) optimization when I moved the blog content so I didn’t really expect any improvement. And sure enough that’s what I saw. No improvement. So what does the WordPress vs Movable Type traffic look like? Here’s the Google organic traffic comparison since the migration and the same period prior.

WordPress vs Movable Type

Sure there’s a 50% improvement but the actual traffic this blog receives is so pathetic that I’m going to happily call that “noise”. Perhaps no-one is interested in what I write (so sad) or perhaps there’s a lot more to SEO than on-site factors.

What Next?

I guess as I find time I’ll work my way back through older posts and make use of the Yoast SEO plugin a little better. In the past I’ve generated posts with little (actually no) regard to SEO at all. That’s because this blog is really just a little bit of fun for me. There’s a learning opportunity though, if I can make this blog perform better in the SERPS just through the use of the WordPress blogging platform and a bit of effort with the Yoast plugin then it may be worth the gargantuan effort of migrating one of my product websites to the same platform. Because of that, I’ll have to make sure I find the time to improve my post archive and see what benefits I see over the old Movable Type platform.

Installing the PHP MCRYPT Extension on Ubuntu

I use the PHP mycrypt extension to generate some encrypted URLs for one of my online applications. I had reason to test some of this functionality on my local development web server recently and the following error was thrown by PHP:

Call to undefined function mcrypt_create_iv()

Turns out that I didn’t actually have the MCRYPT extension installed on my little Ubuntu web server. Doing so was simply a matter of typing this at a command prompt:

sudo apt-get install php5-mcrypt

And that’s it. No need to re-start Apache or anything else. Groovy.