Recent

Author Topic: Is it possible to get the editor line number in code?  (Read 409 times)

hedgehog

  • Full Member
  • ***
  • Posts: 135
Is it possible to get the editor line number in code?
« on: June 26, 2026, 10:38:26 am »
Hi

Is it possible to get the editor line number in code?
(and unit name)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12640
  • Debugger - SynEdit - and more
    • wiki

Zvoni

  • Hero Member
  • *****
  • Posts: 3466
Re: Is it possible to get the editor line number in code?
« Reply #2 on: June 26, 2026, 11:42:51 am »
Code: Pascal  [Select][+][-]
  1. program Project1;
  2. {$mode ObjFPC}{$H+}
  3. Uses Sysutils, Classes;
  4. begin
  5.   Writeln('Filename='+{$I %FILE%});
  6.   Writeln('Line='+{$I %LINE%});
  7.   Readln;
  8.  
  9. end.            
Returns
Code: [Select]
Filename=project1.lpr
Line=6

Note: %LINE% returns the Line, on which this Include-Directive is called, not the Line which caused the Exception.
You have to do math there.
See also %LINENUM% which is the "same" as %LINE% but as an integer
« Last Edit: June 26, 2026, 11:44:59 am by Zvoni »
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

hedgehog

  • Full Member
  • ***
  • Posts: 135
Re: Is it possible to get the editor line number in code?
« Reply #3 on: June 26, 2026, 01:28:04 pm »
Thanks, guys. I'm an idiot for forgetting such a simple thing.

 

TinyPortal © 2005-2018