Jump to content
JohnLM

How do I set debugging ranges with-in lines?

Recommended Posts

Because I have arthritis in my fingers, they can be twitchy at times, and during debugging I can go past the point I want to debug and when that happens, other Units open up and I get lost and loose my focus. Its become quite irritating. 

 

Say I am begging within the scope of a tbutton, and there may be 7 lines of code.  I don't want the debugging to continue outside that range or else it will continue loading various Units and that is creating extra work for me and causing me frustration. 

 

procedure TForm1.Button1Click(Sender: TObject);
begin

1

2 -- debugging started via F8. 

3

4

5

6

7 -- stop debugging after this. so if i press F8, debugging will not continue to step past it 7. 

8

9

end;

Share this post


Link to post

I use F4 (Run to cursor) in situations like this ...to skip debugging parts i don't need to debug, but still stops when the program reaches the selected line.

Share this post


Link to post

procedure TForm1.Button1Click(Sender: TObject);
begin
1
2 -- debugging started via F8. 
3
4
5   
6
7 -- stop debugging after this. so if i press F8, debugging will not continue to step past it 7. // move to end
8
9
end;// <== put break point here to stop loading the next block or unit use F9 to resume or f7 to enter

 

By putting a trap at the end lets you use F9 to advance to trap to either move to next routine or F9 to run.  As the program is debugged these traps are last to remove.  

Share this post


Link to post

I am currently using Delphi XE7. I forgot to mention that. 

 

Apparently, there is no switch to turn off debugging after a certain point within a given code block that I may be currently working on. 

 

I saw this: {$D-}

 

But that only works before a routine/function/procedure call.  I can't insert it between some code within a routine. And it doesn't seem to work when I tried.

Oh well.

 

I guess I can only do one thing that will help a little, and that is to use the following idea shown below using i:=i; multiple times, that in the event I do over-press the F8 key, I will catch it in time in order to stop myself from pressing F8 any further. 

procedure TForm1.Button1Click(Sender: TObject);
var i: integer;
begin 
1 
* 2 -- begin debug breakpoint - i have a breakpoint set it. and i press F8 to setp through the lines of code. . .
3 
4 
5 
6 
7 -- end debug breakpoint . . .until i reach this line, i want the debugging to stop
8 
9 i:=i;
11 i:=i;
12 i:=i;
13 i:=i;
14 i:=i;
15 
end; 

 

Edited by JohnLM
spelling

Share this post


Link to post

A bit tedious, but you can set a breakpoint by pressing F5 in each line from 2 to 7 and use F9 instead of F8. (Not that I would rate that a good solution, but my perception may be different than yours.)

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×