Saturday, 22 May 2021

VAT's in it for me? - or I call my layer.

 - or a shout-out to the various services of

Sorry about the intended pun in the title - but it will all make sense.

Have you ever wanted to know the various VAT rates in the EU - no? - well neither have I, because it might put me in a bad mood, but it fits the intended pun for the post, and I also wanted to show how it is done from from Delphi.

The mother company of Embarcadero, Idera acquired another company early this year - this time, which provides numerous "simple" cloud-based API services - among these are:

  • IP geolocation and reverse lookup
  • Language detection
  • Mail address validation
  • Phone number validation
  • Flight tracking
  • Currency conversion and rates (including crypto currency)
  • Weather data and forecast
  • News, Headline and Stock apis
  • Conversion PDF and scraping
But go to, and read more about their various layers and tiers for these.

We will in this short demo look at the vatlayer - which does EU VAT stuff.

So I started by signing up for the free tier on - which gives you an API access key and access to a dashboard. As always do not share the access key - just saying.

Now you can fire up Delphi, create a new application and either use the REST Debugger or just manually throw in the REST component or create runtime - what you prefer.

I just threw in a edit control and a couple of memos and buttons, as seem above. And then I added an parameter on the RESTClient with the access_key - since I wanted to clear the request parameters on the RESTRequest, but keep the access_key. And set the BaseURL property to

I just took two of the methods/resources from - so the VAT lookup button looks like this:

  json: TJSONValue;
  RESTRequest1.Method := rmGET;
  RESTRequest1.Resource := 'validate';
  RESTRequest1.AddParameter('vat_number', LabeledEdit2.Text, pkGETorPOST);
  if RESTResponse1.StatusCode=200 then
    json := RESTResponse1.JSONValue;

..and the VAT rates for HU (since they have a higher VAT rate than DK :D) button looks like this:

  json: TJSONValue;
  RESTRequest1.Method := rmGET;
  RESTRequest1.Resource := 'rate';
  RESTRequest1.AddParameter('country_code', 'HU', pkGETorPOST);
  if RESTResponse1.StatusCode=200 then
    json := RESTResponse1.JSONValue;

There nice twists to these - by IP address or get list of rate types - and if combining these services by - I could make a speeding white-van "whistle-blower" mobile app - since all company owned registered vehicles in DK - need to have their VAT numbers on their fleet.

So I could lookup the company and their address, get their phone number by a different api layer - and then call and tell on them - MUHAAHAAAHAA (evil laughter)

..or maybe I should just create something useful and fun.

And the best part about writing this post, I now learned that Denmark has only the second highest VAT rate in EU :D


Monday, 15 February 2021

Closing in on Modal Jump Lists

- or getting a WM_SYSCOMMAND to a modal dialog.

An idea that initially seemed clever, has been haunting me a bit lately - I did put a modal dialog into a project before the main Application block (Initialize .. Run). Shame on me.

So the code looks similar to like this:

if (TfrmLaunchSetting.Execute = mrOK) then
  Application.MainFormOnTaskbar := True;
  Application.Title := 'MyApplication';
  Application.CreateForm(TfrmMain, frmMain);

and the TFrmLaunchSetting.Execute is just a class function returning the ModalResult, from its ShowModal.

But here comes the issue at hand - the Close Window in the task bars Jump List sends a WM_SYSCOMMAND that goes to the system menu in the main window - but if a modal form is shown the main window is disabled - and in this case I do not even have a main form yet.

So TApplication.HookMainWindow to the rescue - that would enable me to intercept messages sent to the main form - and act upon these.

So in the FormCreate of my modal dialog I hook the my hook function up like this:


And on FormDestroy I do the following:


The AppHookFunc goes as follows:

function TfrmLaunchSetting.AppHookFunc(var Message: TMessage): Boolean;
  Result := False;
  if Message.Msg = WM_SYSCOMMAND then
    PostMessage(Handle, WM_CLOSE, 0, 0);
    Result := True;

This way modal dialogs can react to Windows messages that normally be intended for the main form.

There are probably side-effects - but the issue at hand is solved - for now?

BTW: Yesterday was Delphi 26th birthday - I did not forget - but I am still wrapping up the present. Stay tuned.


Wednesday, 30 December 2020

It deploys and runs - what a Big Sur prize

- or the initial steps to get a Windows IDE to run cross-platform using CrossVCL.

Sorry about the pun, and I should also mention that this project is WIP, so no workable release/code yet.

Update: In the original image above the language selection was broken/disabled. Read the update in the end of the post on the changes I decided to do to makes this work better overall.

A few days back was a new update of CrossVCL announced in my email - for the lifetime license I had bought years earlier - which triggered an idea.

Saturday, 28 November 2020

A Set back?

- or how could I forget some set operators.

Recently a colleague of mine asked me to review some old code, and a line similar to the one below pop into my view as strange:

if (doorStates * [dsClosed, dsUnlocked] <> []) then

It had been so many years since I had used that specific syntax, that I completely forgot about some of the set operators in Pascal and Delphi - so I thought I would write up a small post on Sets in Pascal/Delphi.

In regards to the silly doorStates example above - here is a little riddle: When is a door not a door?

Saturday, 31 October 2020

Not exactly Kierkegaard - pun intended

- or the books on Delphi keep coming.

Well the pun in the title would probably need a bit of explaining, so the reference is to Søren Kierkegaard (1813-1855) - the Danish philosopher, theologian, poet, social critic and religious author who is widely considered to be the first existentialist philosopher - but his surname is also pronounced as the Danish word for graveyard or churchyard.

I sometimes still hear people say, that nothing is happening in relation to Delphi in general or more specific in the Delphi book area - but that is not true.

It might have been many years since a Danish book on Delphi was published - but there where many in the early days - I had only 2 of the 15-16 published, all the rest I had were in English. So the scene for Danish Delphi books does feel like a "kirkegård".

And it is all my fault - I do prefer my technical books (and my software) in English, and I am sure most Danish developers feel the same.

But when you look at the number of English books that has been published the last couple of years - the technical quality, the passion, level of detail and diversity of topics matches greatly what also has been going on in the rest of the Delphi community - if you haven't noticed you might be looking in the wrong places.

Fellow Embarcadero MVP Patrick Prémartin has started to setup a nice site called - some books still need to be added at the time of writing this. - no books in the Danish section yet - but covers are scanned. Update: Patrick has uploaded the info and covers I provided him with - and also published an extensive open-data API for the site.

I know Patrick has grouping by "year published" on his to-do list, that will help indicate how much great content has been published in traditional book form the latest years - so a big thanks to all the authors and publishers - for keep doing this non-trivial task of writing books.

It is almost 30 years since I co-authored two books on Paradox DOS - in Danish and just prior to Paradox Windows was launched - they were not bestsellers btw 😁. But I still remember the tolls it took on everyone, and still surprised that my then to-be-my wife, stayed.

/Enjoy some of these great books.

Wednesday, 30 September 2020

Good on ya, mate!

- or a shout-out for Alister Christie's new book: Code Faster in Delphi.

I just got a chance to review the first of a series of new books about Delphi from Alister Christie, and even if it is a short book - 160 pages - it is perfect and on the spot - looking forward to the next in the series.

You can get the book here: - just take a look at the Table Of Content - a lot of great stuff.

Alister Christie has been doing his for many years - and his 150+ short videos are always to the point - on topic and precise - at least those I have seen :)

And speaking of video - watch his promotional video for the book - always fun and this one has WordStar bits :)

I will get my dead tree version as well - even if shipment cost probably will exceed the price of the book - but I want this nice books content and cover on my bookshelf.

Speaking of cover - as a little bonus I found this on 99designs: - so if anyone has a potential writer in them, this shows one process of getting a nice cover selected.

It has been more than 25 years since I last wrote a book - even if self publishing and cover contents are now a thing - it is not a trivial task - as I remember it, so well done - and thanks.

/Enjoy Alister's new book.

Monday, 31 August 2020

Hygge by the fireside

- or a fireside chat with Jim McKeeth

End April in the evening Jim and I had a fireside chat, which should had been in front of our masonry oven - but I ended up having it from my home office.

You can see the chat here - it is a bit long but I think we had fun, and to help you through it, I have done this post as a commentary track, and put a bit more details in various places.

And the word hygge now seems to have gotten into the Oxford English Dictionary - but still pronounced wrong :)