Recent

Author Topic: Option to display the line no, function, filename with Writeln and DebugLn?  (Read 3200 times)

vfclists

  • Hero Member
  • *****
  • Posts: 1165
    • HowTos Considered Harmful?
Are there some options or macros to display the line number, function name and, filename with Writeln and DebugLn?
Lazarus 3.0/FPC 3.2.2

molly

  • Hero Member
  • *****
  • Posts: 2330
Nope, at least not automagically and that i am aware of.

Using $I is a tedious job and does not all that you seem to want.

In case you are able to use it, take a look at GetLineInfo

You can feed that with results from routines like get_pc_addr and get_caller_addr for example.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12528
  • Debugger - SynEdit - and more
    • wiki
Create yourself a code template (menu "tools")

for example a template for "d", that contains
Code: Pascal  [Select][+][-]
  1. debugln(['$ProcedureName() ', {$I LINE},|]);
(check "enable macros")

when you enter d followed by ctrl-j in the editor you get the debugln.

ProcedureName() is replaced immediately, if you edit the procedures name later, it is not updated.

vfclists

  • Hero Member
  • *****
  • Posts: 1165
    • HowTos Considered Harmful?
Create yourself a code template (menu "tools")

for example a template for "d", that contains
Code: Pascal  [Select][+][-]
  1. debugln(['$ProcedureName() ', {$I LINE},|]);
(check "enable macros")

when you enter d followed by ctrl-j in the editor you get the debugln.

ProcedureName() is replaced immediately, if you edit the procedures name later, it is not updated.

Thanks. The LINE requires % signs around it. ie:

Code: Pascal  [Select][+][-]
  1. debugln(['$ProcedureName() ', {$I %LINE%},|]);

For anyone else who finds it useful there is more info at http://lazarus-ccr.sourceforge.net/fpcdoc/prog/progsu38.html#x45-430001.1.38
Lazarus 3.0/FPC 3.2.2

 

TinyPortal © 2005-2018