Recent

Author Topic: Creating new Message with Procedurenames  (Read 4411 times)

ratmalwer

  • Jr. Member
  • **
  • Posts: 57
Creating new Message with Procedurenames
« on: November 22, 2021, 01:04:27 am »
Hi folks

i try to develop a new messagewindow-funktion (similar to showmessage).

but it should show besides the text the procedure and unit it is embeded.
As I will use it maybe only at designtime it could be in connection to the debugger if necessarry.
Probably someting that never works, but I have to ask.

What I have in short:
Code: Pascal  [Select][+][-]
  1.      //This works
  2.      FormMSG.Memo1.lines[0] := Screen.ActiveForm.name;
  3.      FormMSG.Memo1.Append(screen.ActiveControl.Name);
  4.      FormMSG.Memo1.Append(msg);
  5.  
  6.      //This is phantasie
  7.      FormMSG.Memo1.Append(laz.ActiveUnit.Name);
  8.      FormMSG.Memo1.Append(laz.ActiveFunction/procedure);
  9.      FormMSG.Memo1.Append(laz.ActiveFunction/procedure-Tree);
   

Any hints, besides thats not possible?

bytebites

  • Sr. Member
  • ****
  • Posts: 473

ratmalwer

  • Jr. Member
  • **
  • Posts: 57
Re: Creating new Message with Procedurenames
« Reply #2 on: November 22, 2021, 07:27:33 pm »
Thanks bytebites

this coul be a approach.

What I have so far is this witch works..

Code: Pascal  [Select][+][-]
  1. MsgTest('My short message. '   ,{$I %LINE%},{$I %FILE%});
  2.  
  3.  
  4. procedure MsgTest(msg:string;Line,Source:String);
  5. var i : Integer;
  6. begin
  7.      FormMSG.Memo1.clear;
  8.  
  9.      FormMSG.Memo1.Append(msg);
  10.      //Display only when Lazaus is active (for develop-purposes)
  11.      if processExists('Lazarus.exe') then begin
  12.         FormMSG.Memo1.Append(' ');
  13.         FormMSG.Memo1.Append('Source: ' + source + '   Line: ' +Line);
  14.      end;
  15.  
  16.      FormMSG.ShowModal;
  17. end;


The procedure can easely be inserted with a macro (I Just lernt this today).
Unfortuately the code looks now quite ugly with the red includes... - but I will change the color ans see if i get happy with that...

I am close at my goal. Still hoping I get the same result without sending parameters to the procedure.

 

TinyPortal © 2005-2018