?
Solved

Break on variable change

Posted on 2001-07-31
10
Medium Priority
?
1,120 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

764 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