Monday, December 22, 2008

Firebird flies

Yesterday and today I converted my 'cinema/dvd library' database program to work with Firebird. Like everything else, at first my steps were hesitant, but by the end, the conversion went quickly. I was even able to revise parts which I had already converted.

As opposed to the first program which I tried to convert, 'cinema' is mainly a data-out program. Getting data out of a database is always easier than entering it, and the speed of conversion reflected this.

There was only one minor sql syntax change needed: when I was using the BDE, if I wanted to sort by a calculated field, I would have to use an alias:
select,, count( as cnt
order by cnt desc

This doesn't work with dbExpress/Firebird, and has to be expressed as
select,, count(
order by count( desc

Thursday, December 18, 2008

BIts and pieces

The most important part of a television is its remote control. This has been brought forcefully to our knowledge over the past fortnight, ever since our remote stopped working. Such things didn't matter when I was growing up, as in those days we had only three television channels which could be hand tuned. Now we have over forty, plus AV inputs for dvd and video. It's impossible to get the tv to use those AV inputs using the manual controls. Fortunately today I finally got a replacement remote, and hopefully it will work with our tv.

On the way to get that remote control, I walked several kilometres in Tel Aviv. We are near the end of December, and the temperature was around 25 degrees Centigrade! I read an entry in Jeff Duntemann's diary about the temperature being minus 6 degrees - and he's using Fahrenheit. This works out to around minus 20 degrees Centigrade! There's a bit of a difference in temperature between where he is (Colorado) and I am (Israel).

But as we know, temperature is only a relative sensation: we can only say whether things are hot or cold, as opposed to saying 'hmm, it's 16.4 degrees in this room, better turn the heat on". So when I wake up in the morning and move from a warm bed into a cold living room, I only know that I am in a colder environment, and rely on the thermometer to tell me that it's 16 or 17 degrees. That could be the temperature of someone's warm summer day.

Tuesday, December 16, 2008


After writing on Sunday that I had 'cracked dbExpress', I went home confidently and tried duplicating Dr Bob's code. Nothing worked, and I got the same error messages as I had been getting previously from my own code.

Yesterday I looked at my code and Dr Bob's again, and eventually found what the secret ingredient was. It transpires that my test databases had been defined as 'sql dialect 1', whereas I was trying to access them as 'sql dialect 3'. Dr Bob's code used 'sql dialect 1', which is why it worked.

Following this eureka moment, things really did start falling into place, and I spent another hour or so tidying up code and trying different possibilities. I still have a few more ideas to check out which hopefully will make the code slightly more efficient.

Sunday, December 14, 2008


One of the programs which I have developed for my occupational psychologist needs to transfer relatively large amounts of data around the network, as it is retrieving pictures from a database. We have found that it is possible to work with this program only if the data resides on the same computer on which the program is running. This is not acceptable as we ideally want an administrator to update the 'clever' parts of the program from one computer, a secretary to enter new people's data from another computer, and people to sit the program's exams from other computers. Eventually we even want the program to work as standalone (I managed to convert our other programs to standalone by using stringtables).

Enter Firebird. This is a sql database manager (RDBMS) which can run as an embedded application, and so theoretically solve all our problems.

Downloading and installing the RDBMS was very easy, and within minutes I had set up a simple database, with the goal of accessing this from a Delphi program. Then the fun began.

I tried different sets of components before settling on the dbExpress set (to be honest, I could have stayed with the InterBase component set which comes with Delphi 7, as this seems to be equivalent). Unfortunately I couldn't find much documentation, and whatever sample programs I did find worked in such a way that all the data from a table was downloaded whenever a query was opened. As this seemed to be the complete opposite of what is needed from a db program (download as little as possible), these samples weren't much use.

I managed to cobble a program together which actually worked, but this required a fair amount of coding (especially coding insert and update queries) as opposed to letting the components do their work automagically. There had to be a better way, I kept telling myself.

Eventually I stumbled on some code by Dr Bob (not the Muppet), which at least showed the way to writing the code which I wanted. There was still a certain amount of work which I had to do myself, but eventually I nailed it. Now I have working code which can either insert a new record into a table, or take an existing record and edit it, posting the results back to the table.

Now this task is done, porting my application from BDE to Firefox will be fairly easy, if tiresome.

Thursday, December 04, 2008

Learning to walk

I've been going to physiotherapy twice a week since I recovered sufficiently from my accident. Most of the time, the treatment is "traditional" - massages and exercises of various kinds. Most weeks, the flexibility of my left foot is measured with a tape measure, which gives an idea of how much progress is being made (it seems that in the past week I have made negative progress).

This isn't to imply that everything is traditional: today I spent six minutes on an exercise bicycle, pedalling at just over 20 kph, and so managed to "travel" a shade over two kilometres. During most visits I also have ultrasound treatment; as opposed to the kind of ultrasound with which the body is explored (not only during pregnancies; I had a chest ultrasound a few months ago), this kind warms up the muscles within. To misquote an advert for beer from my childhood, it reaches muscles that other kinds of treatments can't. Presumably these treatments do have some effect although it's not obvious.

But today we made the leap into the 21st century with a neat piece of medical technology. In order to measure how well I am walking, an inflatable sole was inserted into my shoe. This sole has pressure sensors within, and is connected to a control box which was strapped to my leg with velcro. In turn, this box transmitted its telemetry to a nearby computer. When walking, one places pressure first on the heel and then on the toes; the apparatus measured how much pressure I was applying to these two areas.

Walking 'normally' with the apparatus showed that I was applying 100% of the 'normal' pressure on my left heel but only 50% of the normal pressure on my toes. The apparatus was then switched into learning/feedback mode, which meant that it beeped whenever I applied the correct amount of pressure on my toes. Whilst walking in this mode, I realised that I had been pressing my heel and then the arch (the area just before the toes) on the ground, but not the toes themselves (because it still hurts slightly). In order to get the apparatus beeping, I had to walk making sure that I touch three areas on the ground: heel, then arch, and then push off with the toes. After a few practice runs, in order to learn the new technique, the apparatus was put back into diagnostic mode; my heel pressure had reduced to 80%, whereas my toe pressure had increased to 80%.

I am reminded of an incident in a book by Robert Silverberg called 'The second trip', in which a 'newborn' soul is transported into an adult body. In the first few pages, the character has to teach himself how to walk in a foreign body, and he strides down a boulevard muttering "heel and toe, heel and toe". In real life, we learn how to walk in the second year of our life, and the technique becomes imbedded in a neural pathway, allowing us to perform the action without thinking about it again. So for the next few days, I am going to have to walk with a conscious style, in order to teach my brain what to do.

I have to reburn that neural pathway and teach myself again how to walk properly.