Solved

Break on variable change

Posted on 2001-07-31
10
1,085 Views
Last Modified: 2012-05-04
I am using Delphi 1, and I want to know if I can set a breakpoint using debug, but only break when a variable changes?

i.e.

I set a watch on VarName and I want the program to beak everytime the value of VarName changes.
0
Comment
Question by:Brenda-Leigh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 4

Expert Comment

by:YodaMage
ID: 6338598
I cheat when doing this. Use a test function like this and it'l do what you want:

procedure TestVarandBreak(VarName : Integer);
var
  value2 : Integer;
begin
  if (VarName <> value2) then
  begin
    Showmessage(inttostr(Val2) + ' changed to ' +
     inttostr(VarName));
    Val2 := VarName;
  end;
end;

Then call this in your loop or when you assign Varname.

 
 
0
 

Expert Comment

by:Yevgen
ID: 6338774
Who's using Delphi 1??? Isnt it a little bit old???
0
 
LVL 21

Expert Comment

by:ziolko
ID: 6339455
Yevgen in some places Windows 3.1 is still used !!!!!. Funny, strange but real.
ziolko.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Brenda-Leigh
ID: 6340008
Geez, didn't anybody ever hear of maintenance of legacy software?
Aside from that
The application is extremely large, and in the DLL that I want to capture my variable there nearly 100 procedures, so calling the showmessage isn't really practical. But thanks for the idea.
0
 
LVL 3

Expert Comment

by:raidos
ID: 6340501
If you set up a dummy Class that looks something like this.

  TDummyClass = Class
    fVariable : Integer;
  private
    Procedure SetVariable(Value: Integer);
    Function GetVariable: Integer;
  public
    Property YourVarName: Integer Read GetVariable write SetVariable;
  End;

Procedure TDummyClass.SetVariable(Value: Integer);
Begin
  If Value <> fVariable Then
    fVariable := Value; //BreakPoint here
End;

Function TDummyClass.GetVariable: Integer;
Begin
  Result := fVariable;
End;

  Then you will need a global variable for you class. which will need to be created when you initialize the dll, and freed when you close the dll.
  DummyVar : TDummyClass;

  At init, do
  DummyVar := TDummyClass.Create;
 
  At deinit do
  DummyVar.Free;

Then replace every call to set your variable with
  DummyVar.YourVarName := YourNewValue;
 
Atleast thats how i would do it

//raidos
{Code actually tested in D1}
so it should work..=))
0
 

Author Comment

by:Brenda-Leigh
ID: 6341568
Obviously you went to quite a bit of trouble, so thank you very much. I am not sure though that I see the difference in what you suggest and just putting a break point everywhere I call the variable. Which is what I eventually succumbed to(43 breakpoints!). I was hoping that there was some inherent utility in Delphi's Debug that would allow you to do that, after all VB, C++, and even RPG will let you specifiy a condition to break on. Then rather than watching the variable go through all its hoops and loops where the value is not changed, I could just see the call stack when the value actually changes.
0
 
LVL 1

Expert Comment

by:Phoenix_s
ID: 6341947
breakpoint conditions are available in Delphi 5... But I know that is useless to you at this point.
0
 
LVL 21

Expert Comment

by:ziolko
ID: 8730060
Is this Q still open?
ziolko.
0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 8735036
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

To be PAQ/Refund

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Thank you,
Russell

EE Cleanup Volunteer
0
 

Accepted Solution

by:
RotaredoM earned 0 total points
ID: 8822631
Finalized as recommended.

Question PAQed and 50 points refunded.

RotaredoM
CS Mod @ EE
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question