Recent

Author Topic: Code Trace for Debugging - MacOS  (Read 1350 times)

c_knowles4834

  • New Member
  • *
  • Posts: 25
Code Trace for Debugging - MacOS
« on: August 28, 2021, 03:15:21 pm »
Hello all,

I have been working on a simple application for a calculator in my spare time. For the sake of debugging my application, I would like to add a code trace that would show the outputs of my calculator as I give the program inputs by pressing buttons on the UI. 

It would look something like the following:

Code: [Select]
Start of Calc Trace
<Date MMDDYYYY= "8/22/2021"/>
<Time HH:MM:SS XM= "15:01:05"/>
1 btn3_OnClick 3
2 btnDec_OnClick 3.
3 btn1_OnClick 3.1
4 btn4_OnClick 3.14
5 btn1_OnClick 3.141
6 btn5_OnClick 3.1415
7 btn9_OnClick 3.14159 

If anyone understands how to do this, I would appreciate the help!

winni

  • Hero Member
  • *****
  • Posts: 2803
Re: Code Trace for Debugging - MacOS
« Reply #1 on: August 28, 2021, 05:57:47 pm »
Hi!

Add a Listbox to your 11 Buttons.

Create a procedure procedure TForm1.ButtonallClick(Sender: TObject); 
and connect it with the onClick event of all 11 buttons

Code: Pascal  [Select][+][-]
  1. procedure TForm1.ButtonallClick(Sender: TObject);
  2. var s,cap : string;
  3. begin
  4. if sender is TButton then
  5.   begin
  6.   cap := TButton(Sender).Caption;
  7.   total := total + cap;
  8.   s := TButton(Sender).name +#32 + cap +#32+total;
  9.   ListBox1.Items.add (s);
  10.   end;
  11. end;
  12.  


Screenshot + project attached

Winni

c_knowles4834

  • New Member
  • *
  • Posts: 25
Re: Code Trace for Debugging - MacOS
« Reply #2 on: August 28, 2021, 10:34:41 pm »
Cool, thanks for the help.  I have a question though, should "total" be declared as a string along with "s" and "cap"?

Also, is there any way that I could have that specific trace show up in a separate terminal window? 

Thanks!

 

TinyPortal © 2005-2018