Getting the current line number in Delphi

Note to self: There is an easy way to get the current line number in Delphi, using the following function and JclDebug: [delphi] function GetCurrentLineNumber: Integer; var ModInfo: TJclLocationInfo; begin ModInfo := GetLocationInfo(ReturnAddress); Result := ModInfo.LineNumber; end; [/delphi] ReturnAddress is a compiler magic function in the system unit, introduced with Delphi XE2. TJclLocationInfo and GetLocationInfo … Continue reading Getting the current line number in Delphi

In recent Delphi you cannot rely on dividing by zero to raise an exception

This is mostly a note to self: Having been stuck with Delphi 2007 for many years I didn't notice that dividing floating point values by zero no longer raises an exception in recent Delphi versions. Apparently this changed around the time of Delphi 10.1, even though I found a blog post by Dalija Prasnikar saying … Continue reading In recent Delphi you cannot rely on dividing by zero to raise an exception

Debug visualizers for my TNullable types

My dzlib contains several nullable data types which internally use an interface field to maintain the IsValid value as originally suggested by Alan Bauer in a post on his long defunct Codegear blog "The Oracle at Delphi" (links to the Internet Archive). Today I added debug vizualizers for these types to my dzDebugVisualizer package. Rather … Continue reading Debug visualizers for my TNullable types

(Multi line) string Debug Visualizer for Delphi 10.2

The (multi-line) string Debug Visualizer previously available for Delphi 2005 to 2007 is now also implemented for Delphi 10.2 using the OTAPI interface. It shows the content of a string without quotes and with line breaks if it contains any. The implementation was much more complex than I thought. Originally I just used a simple … Continue reading (Multi line) string Debug Visualizer for Delphi 10.2

TColor debug visualizer for Delphi 10.2 and 12

I just extended my dzDebugVisualizer package to include a TColor debug visualizer for Delphi 10.2 and Delphi 12. With little change these will probably work for every Delphi Version that supports the neccessary ToolsApi functions, meaning >= Delphi 2010. This is completely different code than I used before, but it still shows the color name(s) … Continue reading TColor debug visualizer for Delphi 10.2 and 12

That was easier than I thought – yeah, right

In my last post I announced that the GExperts code formatter now supported multiline string literals and boasted that this "was easier than I thought". Turns out that it was actually more complicated. I should have known immediately because two of the existing unit testes failed, but somehow I didn't notice that. Consider the following … Continue reading That was easier than I thought – yeah, right

GExperts Code Formatter now supports multi line string literals, but …

... but only in the code currently in SVN. There is no new release yet. That was easier than I thought: As of revision #4112 the formatter now actually does support multi line string literals. And only those unit tests that already failed still fail. Of course that does not mean that I have not … Continue reading GExperts Code Formatter now supports multi line string literals, but …

GExperts Code Formatter does not support multi line strings

I expected this but just confirmed it: The GExperts code formatter does not handle multi line strings correctly (bug #337) For now the workaround is using the comment to prevent formatting (configured on the Misc tab of the formatter configuration dialog): Use it like this: [delphi] const {(*} bla = ''' first line seconde line … Continue reading GExperts Code Formatter does not support multi line strings