Today’s been spent catching up on podcasts while getting a code editor sorted out and doing some prep work on DataTech.

Podcasts

Several podcasts have been building up in my iTunes playlist, so it’s been a good opportunity to work through them today.

  • This Week in Tech (TWIT) is about all things tech, with a roundtable discussion going on about the latest news and events occurring in the tech space.
  • Security Now is exclusively about computer security, and features Steve Gibson who wrote SpinRite which an excellent mass-storage maintenance and recovery utility.
  • No Agenda is an anarchist right-wing liberal show that covers all sorts of strange things from the realm of US political news. While I don’t agree with much of their content, I still feel that it’s important for the purpose of contrast.
  • Scriptnotes is a very good show by two script writers, John August and Craig Mazin that delves deeply into the techniques of writing and making good movies.

I’ve managed to catch up with all the above except for Scriptnotes of which I have half a year to still catch up with, and given that I’ll be spending more time at the keyboard with DataTech I suspect that I’ll be able to power through the remaining podcasts in just a few weeks.

Sublime Text 3

Sublime Text has become my favourite code editor, replacing Notepad++ from my toolkit. Sublime is not a free product, so given the free competition that’s out there it had to be much better than the free competitors to be worth paying for.

Today I’ve been setting up Sublime to work well with the Clipper/Harbour code of DataTech. Adding a definition language for Clipper was a good start, and setting up custom indent preferences for the code was as simple as editing a syntax-specific setting file:

Harbour.sublime-settings

// Settings in here are specific to Harbour files
{
    // The number of spaces a tab is considered equal to
    "tab_size": 3,

    // Set to true to insert spaces when tab is pressed
    "translate_tabs_to_spaces": true,

    // Set to false to disable detection of tabs vs. spaces on load
    "detect_indentation": false
}

The tab size is 3 spaces throughout most of the code which differs from my normal 4 spaces, and because it’s more important to code where practical to the existing style,  having custom settings so I don’t have to manually switch back and forth is vital. Sublime also auto-detects the tab size when it loads a file, and due to the inconsistent indentation of the existing code, kept on thinking that a tab size of 2 should be used instead. So turning off the detection just for these Harbour files is important until issues with the code can be fixed so that auto detection doesn’t get as confused.

My cleaning up of the code today consists of working through all of the code and figuring out which functions are called from elsewhere, which ones are called just from within the same file (and can thus be made static) and which functions are not called at all. I’ve been realising that information at the top of each file is out of date, so I’m adding info about static and non-used functions, which is a good way to work through all of it and gain a better idea about it. The idea is to end up with the following sort of info about each file.

/* Program.....: XF_HIST.PRG
   Authors.....: J.Kirby, P.Wilkins
   Date........: 6/10/1998
   Functions...: HistName, Mu_Hist, SuplHist, NameSale
                 HistPart
   Static funcs: QOName, QOrdName, PartSale, NameSaleHd
   Not used....: HistList, HistLsthd, HistSerno, SernoEdit
*/

It’s fairly easy to update the above information, because Sublime makes it easy to search all of the files to show you where things are used. There was an initial teething problem though where no text was shown for each file in the search results, because Sublime thought they were binary files. Removing an annoying Ctrl-Z code from the end of each file results in excellent search results now being available.

Also while doing that, it’s also good opportunity to ensure that I can use code folding so that the functions can be folded away, which helps to ensure that at least a minimum amount of good code indentation is there. My process then ends up being, to indent each function so that it can be folded up, and when all functions are folded to then remove the function info from the header block, and search for each function name throughout all of the files. This lets me figure out whether it’s static, not used, or used across multiple places, so that I can update the header with correct information about that.

With 99 files containing 619 functions, and consisting of 104,977 lines of code, all weighing in at 3.7 megabytes of code – this is equivalent to around 10 books of text and is a vast amount of code to work through, but thanks to using plenty of shortcuts every last piece of it has been successfully worked through today and been updated, with neatly folding functions now. There are a huge number of functions that contain vast amounts of duplication, but that’s something to work on later on.

Obsessive compulsive

Lastly, I came across a funny aspect about Yahoo Groups today. They only allow 40 characters for their group name, which causes certain problems when a group name needs to be slightly longer.

Obsessive Compulsive Personality Disorde

Advertisements