I'm pleased you indent your code properly, so many people don't and just produce a clumsy mess. Nothing to do with the topic but I thought I'd give you a bit of praise anyway
Although it would much more concise in Delphi
Although it would much more concise in Delphi