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:

function GetCurrentLineNumber: Integer;
var
  ModInfo: TJclLocationInfo;
begin
  ModInfo := GetLocationInfo(ReturnAddress);
  Result := ModInfo.LineNumber;
end;

ReturnAddress is a compiler magic function in the system unit, introduced with Delphi XE2. TJclLocationInfo and GetLocationInfo are from JclDebug.

Use it like this:

WriteLn(GetCurrentLineNumber);

Edit: JclDebug already contains a function LineByLevel which does the same as my function above and more. There are other useful functions there, like TraceLog.