Android Question Stop code flow and start debug

RB Smissaert

Well-Known Member
Licensed User
In VB6 and VBA we can do this:

If i = 1000 Then
Stop
End If

and the normal code flow will stop if i = 1000 and we can step into debugging mode.

Can we do this is B4A?


RBS
 

Sandman

Well-Known Member
Licensed User
Yep. Just set a breakpoint at the line where you want to enter the debugger. I don't think that Stop will work though, just use a Log("text here") instead, and put the breakpoint there.
 

RB Smissaert

Well-Known Member
Licensed User
Yep. Just set a breakpoint at the line where you want to enter the debugger. I don't think that Stop will work though, just use a Log("text here") instead, and put the breakpoint there.
I tried that, but the breakpoint gets ignored.
I have a long loop and only want to start stepping through the code after the loop counter gets close to the end.

RBS
 

Sandman

Well-Known Member
Licensed User
There are some subs where the debugger won't work, but I don't remember which one's at the moment. I'm sure you can find more info about them here in the forum if you use the search function.
 

RB Smissaert

Well-Known Member
Licensed User
There are some subs where the debugger won't work, but I don't remember which one's at the moment. I'm sure you can find more info about them here in the forum if you use the search function.
This is just a plain normal Sub, so no Resumable Sub or anything else unusual.
I did search the forum, but couldn't find anything about starting debugging after x iterations of the loop.

RBS
 

Claudio Oliveira

Active Member
Licensed User
Try putting your breakpoint inside an IF...ELSE statement.
Something like this:
B4X:
For n= 0 to 1000
    ... some processing
    IF n=950 then
        Log("Breakpoint reached")  <---- Put a breakpoint in this line
    End If
Next
This way, the code will stop only when the IF condition is met. From then on you can step through the rest of your code.
 

RB Smissaert

Well-Known Member
Licensed User
Try putting your breakpoint inside an IF...ELSE statement.
Something like this:
B4X:
For n= 0 to 1000
    ... some processing
    IF n=950 then
        Log("Breakpoint reached")  <---- Put a breakpoint in this line
    End If
Next
This way, the code will stop only when the IF condition is met. From then on you can step through the rest of your code.
Ah, OK, my breakpoint was on an empty line. Of course it need to be on a code line!
Thanks.

RBS
 

Claudio Oliveira

Active Member
Licensed User
There are some subs where the debugger won't work, but I don't remember which one's at the moment. I'm sure you can find more info about them here in the forum if you use the search function.
AFAIK you can't set breakpoints only in Activity_Pause (and Globals and Process_Globals of course).
 
Top