Today i finished something i should have done a long time ago, and it took me more time than i had in mind…
In March 2009 i started working on a Homeseer Plugin for the Fritz!Box FON 7170. I had the hardware, created a basic call monitor for myself and because i liked to share this nice feature of this FritZ!Box, i created the Plugin. Over time this Plugin evolved and new functions were added to it, mostly based on user request. The latest that was added to the Plugin was being able to parse the Fritz’s Phonebook and using a internet search engine to find a name with the phonenumber.
Strangely enough, i have been living without this functionality for quite some time, while all the Plugin users did have it.. time to catchup with myself!
So the situation was like this: i created a piece of software in a programming language (VB.NET) that i don’t really use on a daily basis and i wanted to translate this to Delphi, a language that i’ve been using for years and in which i created my complete Domotica system; so how hard could it be? I gave myself 2 hours and it should work. Sounds reasonable? Nope.
It’s those tiny differences that make a small job larger than you would have expected.
A small example. Consider capturing a HTTP response to a string variable and you want to put this response in an array of strings. All the lines in the response are terminated by a line feed (LF, 0x0A, chr(10), etc). In VB you would do something like this:
It works like you think it would, i know 🙂
Translating this to Delphi and knowing that there is a class called TStringList that can be used to maintain a list of strings, this shouldn’t be to hard to accomplish, cause it sounds like something that could do the very same job as the ‘array of String’ equivalent in VB.
But as i said, there’s a tiny difference.. splitting the response into multiple lines didn’t work as i expected… the response was split in a way that it looked like even a space was considered a delimiter! In Delphi, i had to use a different approach and also first replace the line feed (LF) with CR+LF before i got the same effect:
It can take some time to figure out why the Phonebook isn’t being parsed… pfff